In this video I show you how to use a switch statement to check for conditions when the list of conditions may be really long. This is much efficient and a lot more tidy than using lots of if statements.
Don’t forget to subscribe:
http://www.youtube.com/user/QuentinWatt
For collaborations and business inquiries, please contact via Channel Pages: http://ChannelPages.com/QuentinWatt Social links:
————————————————————-
Add me on twitter:
Tweets by QuentinWatt
facebook group:
https://www.facebook.com/quentin.watt
————————————————————-
Original source
40 responses to “JavaScript beginner tutorial 19 – switch statements”
Yes but is this… Okay?
WHen i use a switch statement it works as described in the video, but whenever I add "includes()" to the switch statement it all of a sudden doesnt work.
can't we do this with if,else if, else statement … what is difference?
What's the difference between a switch statement and an if/else statement? And what is the purpose? Like I thought it was supposed to be something shorter or something but it looks like it's just as long and has the same function. I don't get it.
best tutorial!
Thank you for your videos. They are very clear. I am with a problem that I am not sure if this is the best place to ask it. How to create a switch inside a function? Because anytime I write return for each case, when I write down break it doesn't work. I am not sure what I need to change to make it works. Thanks
One question came to my mind after watching this explanation, can I use "||" or "&&" with Switch statements??? like let´s say you would´ve written:
case "dodge" || "ford" :
document.write ("American cars……..etc
WOULD THIS BE AN OPTION???
very efficiently explained, thanks!
Thank you!
hey youthoob! thnx
excellent video sir…
how does the user input the case, shouldn't there be something like
var car = prompt ("Enter you car");
Thanks for posting this!
OK?
Awesome teacher, you explained all the details perfectly! Loved how you explained that a break statement is not needed in the default case. Please do more JavaScript tutorials!!
very helpful indeed thank you
Please Show Us How Can We Make A Nice Programing Language Like JS …
– Thanks For You Simple But Helpful Tutorials
Awesome
great!
Hi quentin!….great explanation….I like your videos.
très bon boulot, clair, net et précis ! bravo. Let's translate french sentence 😉
Lionel from Reunion Island, earth paradise !
Good work man, thanks !!
Quintin, I truly am enjoying your tutorials. I think you represented the break statement inaccurately though on this one. If you don't include the break statement JS continues to execute all following case statements as true. You are doing a great jobs. Thanks.
its colon(:) after case "ferari", but semicolon(;) after document.write()
Mr.quentin in the line of case ("ferari"): u r saying semicolon(;) and typing colon(:).
*Ferrari
I love it……
very much better ALL online training(Lynda.com,Envato,learnable,Tutsplus,…), YOU just born to teach, I have to say Africa loves you.
much better than lynda.com
simply nice tutorial.
When ever i run my code with a document.write statement it does not show up on chrome how does yours show up and i know you are using firefox do i need to get forefox in order to make it work? Thanks
Hi Quentin your vedios are very helpful.You are doing nice thing.
while practicing switch statement, I found if we dont put "break" then all the document.write() are going to be executed even if the first case was true. I thought it will just go inside every case but will not print if a certain case is not true.
I think you are indirectly bankrupting every other JavaScript tutorials
thanks
"american cars cant corner propperly, which is the case" nice last words Qunetin haha
I am so glad that I learned this… I have always been doing if () { } else if () { } but this shortens my code sooooooooo much more
I like how the videos are broken up into nice short and useful lessons.
Your tutorial is one of the best things in this world. 🙂 I'm getting javascript so fast. Your teaching is cool. That's just it, I'm gonna go finish the remaining videos.
Spelling Correction: Ferari: wrong – Ferrari: correct