We cannot use if statement it has o be done using switch only
![]() |
We cannot use if statement it has o be done using switch only
When you write a "boolean statement" (i.e.: the contents of an "if" statement) outside of an "if" statement, it returns either true or false.
Your boolean statement is as follows:
This can become the target of your switch like so:Code:(num < 0)
Code:switch(num < 0) {
case true:
alert('NUMBER IS NEGATIVE');
break
case false:
alert('NUMBER IS POSITIVE OR ZERO');
break
}
All times are GMT -7. The time now is 05:41 AM. |