+ 1

How i can use?

I don't understand how use it

4th Jun 2019, 5:39 PM
LouraD
LouraD - avatar
5 Réponses
+ 7
switch(variable){ case variable: statement ; break; case variable: statement ; break; default: statement ; } when the variable is equal, it execute the expression which have the case
4th Jun 2019, 5:51 PM
✳AsterisK✳
✳AsterisK✳ - avatar
4th Jun 2019, 5:58 PM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 1
Thank you, can you give me an example?
4th Jun 2019, 5:54 PM
LouraD
LouraD - avatar
+ 1
it basically eliminates the need to write multiple if-else if statements e.g. let say you had a basket with three colored balls in it(red, green and blue) switch(ballCol){ case ‘red’: alert(‘red ball selected’) break; case ‘green’: alert(‘green ball selected’) break; case ‘blue’: alert(‘blue ball selected’); break; }
4th Jun 2019, 8:53 PM
Logomonic Learning
Logomonic Learning - avatar
+ 1
For examples and learning Switch Case you can use search bar in SoloLearn and can learn switch in multiple languages.
5th Jun 2019, 5:52 AM
Yashvi Shah
Yashvi Shah - avatar