No video

Switch Statements - Beau teaches JavaScript

  Рет қаралды 76,518

freeCodeCamp.org

freeCodeCamp.org

Күн бұрын

Пікірлер: 58
@bridget7223
@bridget7223 3 жыл бұрын
thank you so much Beau! love your ending tag! "use your code for good" :)
@reidwilliamson6477
@reidwilliamson6477 3 жыл бұрын
Love that too
@user-sz1gu9hz6u
@user-sz1gu9hz6u 10 ай бұрын
Declaring variables in JS is done using keywords such as let, const or var. That's why you see the let keyword in this example. As for why it outputs Friday (I think this is an error on the teacher side), because the Date object in JS has a method getDay which takes his Local Time and on the day of him writting this code it was Friday so it outputs it.
@MiguelVargas-pz5zv
@MiguelVargas-pz5zv 5 жыл бұрын
Got a little lost on how you got Friday for the first example.. If someone can explain that would be great
@ukaszkiepas57
@ukaszkiepas57 5 жыл бұрын
Program got data from his local PC :)
@HarryInShape
@HarryInShape 2 жыл бұрын
@@ukaszkiepas57 I am guessing that's what the command getDay has accomplished right?
@postingbmwm3
@postingbmwm3 2 жыл бұрын
@@HarryInShape correct
@user-yk4yj7gs5w
@user-yk4yj7gs5w 9 ай бұрын
i am very impressed the videos about js and especially buea teacher😍
@jaylavan7392
@jaylavan7392 4 жыл бұрын
Free and concise, nice!
@SF-ve3rc
@SF-ve3rc 4 жыл бұрын
Fantastic explanation
@stephenkamenar
@stephenkamenar 4 жыл бұрын
i don't think i've ever used a switch. they're bad because you have to remember to break; just use else if
@ABunchaHerbs
@ABunchaHerbs 4 жыл бұрын
yeh im just stating out js but I don't rlly understand what break does in this loop
@endyy6671
@endyy6671 4 жыл бұрын
@@ABunchaHerbs take the animal example, let's say using "Spoon". The switch evaluates "Spoon" against Cow, Giraffe, Dog, Pig. Because None of those are true, the code within the switch doesn't execute (so no break or no console log). So, it continues to the next switch statement. This time, it compares "Spoon" to Spoon, which fires back True to the switch. As a result, the code executes, and the console log and break goes through (the break exits the entire switch statement). Let's say he didn't have break there, just console log. Console log would execute, and then it would proceed to the next switch (dinosaur and default). since default will always execute to true, it's basically saying if animal === dinosaur || animal. (that is, animal has ANY value). so the last switch would execute too. As a result, you breaks are used to avoid that happening.
@c0zy23
@c0zy23 3 жыл бұрын
@@endyy6671 thanks!
@chascript
@chascript 3 жыл бұрын
@@endyy6671 awesome explanation!
@stephenkamenar
@stephenkamenar 2 жыл бұрын
@Charlie Ennis they're not bad in languages where you don't have to type break everytime. and yes they are faster. really weird he doesn't mention that here, since that's the only reason to use a switch
@vasilemidrigan50
@vasilemidrigan50 3 жыл бұрын
Thank you Beau!
@reidwilliamson6477
@reidwilliamson6477 3 жыл бұрын
Much love Beau! Thanks for your videos
@simplefit93
@simplefit93 Жыл бұрын
how come when it says Case followed by a number the number is not in parentheses but when it is Case followed by a word or letter they are in parentheses? case 1 case "a"
@islombekmirsalimov3185
@islombekmirsalimov3185 Жыл бұрын
you mean quotation marks? That is because the value can be number (Ex. 1,) or it could be string (Ex. "a"). Quotation marks indicate that that is string.
@Gentarozzo
@Gentarozzo 7 жыл бұрын
Ok dinosaurs are extinct... but poor chickens :(
@fionashaw6935
@fionashaw6935 3 жыл бұрын
Chickens are the direct descendent of dinosaurs tho lol
@philipdufour7233
@philipdufour7233 3 жыл бұрын
dinosaurs >= chickens
@abdullahmazhar9932
@abdullahmazhar9932 3 жыл бұрын
@@philipdufour7233 if(dinosaurs >= chickens) { alert("dinosaurs are bigger then chickens."); }
@chinweikes.okenyi6163
@chinweikes.okenyi6163 2 жыл бұрын
//By their present number on earth var dinosaur = 0; //? var chicken = 300000; //even more if(dinosaur>=chicken){ alert("we have lived way before you")} else { alert("You're a joke, no one knows when you existed")} ;
@syedarmaghanhassan4652
@syedarmaghanhassan4652 3 жыл бұрын
what does let day; mean? let day what? we did not assign any value to this variable here ... Why?
@erichernandez38
@erichernandez38 3 жыл бұрын
its creating a variable but instead of var its let.
@luiscamacho1996
@luiscamacho1996 3 жыл бұрын
Got it now, thank you!
@CiscoZero
@CiscoZero 2 жыл бұрын
How does the first switch case know that it's Friday though? Does it reference some kind of global property?
@BuzzMarketingKe
@BuzzMarketingKe 2 жыл бұрын
Thanks for this.much appreciation
@MilesLogan91
@MilesLogan91 2 жыл бұрын
Can this be done with changing background colors on a webpage? If so how exactly
@orion.5611
@orion.5611 3 жыл бұрын
what is the function of case? why is it there.
@nguyenthanh5719
@nguyenthanh5719 6 жыл бұрын
day in switch is variable?
@kyleyeung1075
@kyleyeung1075 7 жыл бұрын
can i ask which editor u r using?
@wattabak9890
@wattabak9890 7 жыл бұрын
kyle Yeung CodePen, I guess
@BeauCarnes
@BeauCarnes 7 жыл бұрын
Yeah, it is codepen.
@fahimemroz9141
@fahimemroz9141 5 жыл бұрын
@@BeauCarnes Sir, are you Jewish?
@Mogwai88
@Mogwai88 3 жыл бұрын
@@fahimemroz9141 why do you ask?
@fahimemroz9141
@fahimemroz9141 3 жыл бұрын
@@Mogwai88 Just curious
@gilbertquaye1571
@gilbertquaye1571 2 жыл бұрын
Thanks👍
@ukaszkiepas57
@ukaszkiepas57 5 жыл бұрын
Love youuuu
@DIZZYplys
@DIZZYplys Жыл бұрын
thanks, I'm sick of using if statement over and over
@Gummylongtail
@Gummylongtail 4 жыл бұрын
break; not Break;
@climbers1376
@climbers1376 5 жыл бұрын
thank you!!!!! I love freecodecamp.org
@nielsnet4169
@nielsnet4169 4 жыл бұрын
Always the same example given on every videos.....................................................
@adil88201
@adil88201 2 жыл бұрын
pas mal
@kmachappy5176
@kmachappy5176 2 жыл бұрын
please avoid this channel they're terrible at explaining code with the worst examples lmao.
@s.asamoahh8790
@s.asamoahh8790 Жыл бұрын
😂
@peterwoods35
@peterwoods35 5 жыл бұрын
That was a terrible discussion of switch statements;. totally confusing.
@faithpublico9484
@faithpublico9484 3 жыл бұрын
wat
@PhilippeRigovanov
@PhilippeRigovanov 7 жыл бұрын
So you think that all dinosaurs were able to swim?
@BeauCarnes
@BeauCarnes 7 жыл бұрын
That example actually came from the Mozilla Developer Network article on Switch statements. But I think the idea is that dinosaurs were extinct before the arc. 😃
@marciopires4969
@marciopires4969 5 жыл бұрын
It's almost 2019 and this still don't make sense
@typingmasterpro6762
@typingmasterpro6762 3 жыл бұрын
Not described well enough here
@yohanjayawardena4457
@yohanjayawardena4457 2 жыл бұрын
kzfaq.info/get/bejne/i8uId6SmnLnInY0.html check this for a more noob friendly video to get what happens here. cheers.
Arrays - Beau teaches JavaScript
4:06
freeCodeCamp.org
Рет қаралды 19 М.
For Loops - Beau teaches JavaScript
6:37
freeCodeCamp.org
Рет қаралды 95 М.
Whoa
01:00
Justin Flom
Рет қаралды 48 МЛН
Little brothers couldn't stay calm when they noticed a bin lorry #shorts
00:32
Fabiosa Best Lifehacks
Рет қаралды 21 МЛН
While / Do While - Beau teaches JavaScript
4:58
freeCodeCamp.org
Рет қаралды 34 М.
AJAX - Beau teaches JavaScript
6:14
freeCodeCamp.org
Рет қаралды 38 М.
Ternary Operator - Beau teaches JavaScript
4:18
freeCodeCamp.org
Рет қаралды 54 М.
Closures - Beau teaches JavaScript
4:48
freeCodeCamp.org
Рет қаралды 74 М.
Common Array Methods - Beau teaches JavaScript
6:46
freeCodeCamp.org
Рет қаралды 65 М.
Copying Arrays (deep and shallow) - Beau teaches JavaScript
5:56
freeCodeCamp.org
Рет қаралды 45 М.
Learn English with the classic TV show Friends No.1
12:53
English Paradise
Рет қаралды 291
System Design Concepts Course and Interview Prep
53:38
freeCodeCamp.org
Рет қаралды 234 М.
Whoa
01:00
Justin Flom
Рет қаралды 48 МЛН