JavaScript beginner tutorial 19 – switch statements




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:

facebook group:
https://www.facebook.com/quentin.watt
————————————————————-

Original source


40 responses to “JavaScript beginner tutorial 19 – switch statements”

  1. 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.

  2. 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

  3. 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???

  4. 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!!

  5. 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.

  6. 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

  7. 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.

Leave a Reply