+1

i am having problems understanding the switch statement any explanation on it would be welcomed

8/25/2019 10:57:01 PM

jeffrey ogbonnaya

3 Answers

New Answer

+1

Hope this code helps you a bit: https://code.sololearn.com/cCik5HuXBBmd/?ref=app

+2

A switch statement in its simplest terms is just a bunch of else if statements together. To make it neater and more flexible (for longer scripts) a switch statement would be used. An example is Var I = 6; If (I == 3) { Console.write("true"); } else if (I == 6) { Console.write("true"); } Else { Console.write("false"); //outputs true In a switch statement that code would look like this: Var I = 6; Switch(I) { Case 3: Console.write("true"); Break; Case 6: Console.write("true"); Break; Default: Console.write("false"); } //outputs false. You can look at a switch statement program in the js tab here https://code.sololearn.com/WoAnpnUWf6sf/?ref=app

+1

https://www.sololearn.com/learn/JavaScript/1139/