0
Can we have more than two values for the conditional(ternary) operator
4 Answers
+ 1
No, remember that the sintax is as follow:
condition ? expr1 : expr2
The condition is an expresion that evaluates to true or false. If the condition is true the operator returns the value of expr1, otherwise it will returns the value of expr2.
A condition can have multiples "conditions", for example:
// you can use prompt
var num = 12;
(num > 0 && num % 2 == 0) ? alert("Is positive and an even number") : alert("Is negative or odd number");
This case will show Is positive and an even number
0
is the cuestion about the condition or about the result of the condition???
If it is about the result the answer of Gabriel Lopez Garrido is flawless.
If is it about the condition, you can have as many as you want:
if((condition1) && (condition2) || (condition3))...
0
Level.setTime(0); ClientMessage("ITS DAY IN MINECRAFT NOW");
0
clientMessage("HI GUYS"); Level.setGameMode(0);