0

When writing a switch, how can I specify a case in which x is greater than something?

I tried case >7 but it returned an error...

1st Dec 2017, 6:44 AM
Hessam Tayebi
Hessam Tayebi - avatar
1 ответ
+ 3
var x = 8; switch (true) { case (x > 7): alert("x greater than 7."); break; default: alert("x less or equal to 7"); break; } https://code.sololearn.com/W5X1kgU6HWgK/?ref=app
1st Dec 2017, 7:15 AM
Calviղ
Calviղ - avatar