+ 3

Me again....i dont understand the switch statements in javascript

15th Jan 2021, 10:13 AM
Kevin Kiarie
Kevin Kiarie - avatar
3 Answers
+ 5
Kevin Kiarie Check it out following article that will help you https://medium.com/@leeinjae/switch-472d55cf3cbe Hope this code helps you Switch statement is same in other languages check this code if you still got confused you can ask me again https://code.sololearn.com/Wn8yUaU8FIAT/?ref=app
15th Jan 2021, 10:40 AM
R🍁🇼🇳
R🍁🇼🇳 - avatar
+ 3
Hi Kevin Kiarie I am not a Javascript expert, but Switch works like this. Usually in a code you will have a variable which needs to be inspected / compared. You could write a whole heap of if /else statements to check your variable against the comparision. Or you could write a Switch statement which neatly captures all the comparisons into a simple block of code. The cases within the Switch statement are compared to the Switch variable. The code associated to the case will be enabled if the case is true
15th Jan 2021, 10:44 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
I noticed that you have not done the Javascript tutorial here. Doing it will help you.
16th Jan 2021, 12:22 AM
Sonic
Sonic - avatar