Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

ternary if , else if with ternary if

 //else if with ternary if 
 
var x = Number(prompt('Enter number'));
(x < 10) ? 
alert("Your number C") 
: (x >= 10 && x <= 15) ? 
alert("Your number B") 
: (x >= 16 && x <= 20) ?
alert("Your number A") 
: alert("Other");
 
PREVIOUS NEXT
Tagged: #ternary #ternary
ADD COMMENT
Topic
Name
4+5 =