Multiple Logical Check | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Multiple Logical Check

I want to check if the value of var x is between 10 and 30. In if else statement it can be done with if(x > 10 && x < 30){} Can it be done by using switch statement?

18th Dec 2016, 2:43 AM
Fanny Hasbi
Fanny Hasbi - avatar
1 Answer
+ 2
Yes, one example is, switch (x > 10 && x < 30) { case true: // something here ; break ; default ; // something here ; } P.S. default is like 'else' and the cases are 'if's.
18th Dec 2016, 5:25 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar