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

+2

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

Genesis

2 Answers

New Answer

+12

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

+18

Where is the example?