Conditional(Ternary) Operator | Sololearn: Learn to code for FREE!


Conditional(Ternary) Operator

I just wanted to know one thing that is, if we are creating a login page from JavaScript and as the example shows, if the age is <18 it gives error else it proceeds forward with the login. Is that right?

7/2/2018 4:41:13 PM


2 Answers

New Answer


var validateAge=prompt ('enter age') < 18 ? false : true; if(validateAge==true){ //validation code } else{ throw ("not allowed below18"); }


Where is the example?