+ 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?
2 Answers
+ 12
var validateAge=prompt ('enter age') < 18 ? false : true;
if(validateAge==true){
//validation code
} else{
throw ("not allowed below18");
}
+ 18
Where is the example?