case "oranges": alert ( "You selected oranges" ); break;
However, the user would have to type exactly as I did in the case statement, so
oranges would be fine
Oranges would not
ORANGES would not etc you get the point
For that reason, I used numbers, just so it's less work. The way you can get around this though, would be to prompt the user, then make their output all lowercase. This wouldn't work with numbers though, so its one or the other.
thank you so much for the video, you are a great teacher, i also teach a series of video tutorials, so i know how much preparation is required to do a good session. Keep up the good work.
Good coverage of the basic 'switch' statement in Javascript. Didn't know you could have the 'default' statement anywhere in the switch statement, and you made a good point re. the benefit of keeping the default at the end (if you want to execute it anyway regardless of whether other 'cases' are true).
Awesome Work done!
54553400 6 months ago
how can I make the text in the alert statement text bold,italic or change the color ??
Love the tutorials , keep it up :D
YYuMax 1 year ago
I spent like 20 min trying to figure out why my code wouldn't work and it turned out there were 2 typos :P (swich and choise) , ehh it happens.
YYuMax 1 year ago
Is there a way to let the user type either "1" OR "oranges" ?
Love the tutorials by the way. You are brilliant.
I think I'll quit school and just subscribe to you... =)
FeezleT 2 years ago
Yup, you just need to add another case, e.g.
case "oranges": alert ( "You selected oranges" ); break;
However, the user would have to type exactly as I did in the case statement, so
oranges would be fine
Oranges would not
ORANGES would not etc you get the point
For that reason, I used numbers, just so it's less work. The way you can get around this though, would be to prompt the user, then make their output all lowercase. This wouldn't work with numbers though, so its one or the other.
asib12 2 years ago
thank you so much for the video, you are a great teacher, i also teach a series of video tutorials, so i know how much preparation is required to do a good session. Keep up the good work.
juliusctw 2 years ago
Good coverage of the basic 'switch' statement in Javascript. Didn't know you could have the 'default' statement anywhere in the switch statement, and you made a good point re. the benefit of keeping the default at the end (if you want to execute it anyway regardless of whether other 'cases' are true).
Pablos544 3 years ago
I dont even like Javascript, but your so fucking good at it, as soon as you speak I'm like a fucking dog, I listen to everything :P.
Amphion0 3 years ago