let a = prompt("hey whats is your age?");
a = Number.parseInt(a); // converting number into a string
if (a < 0) {
alert("This is an invalid age");
}
else if (a < 9) {
alert("You are kid and you cannot drive now")
}
else if (a < 18 && a >= 9) {
alert("You are kid and you can think of driving after 18 ")
}
else {
alert("you can drive now as you are above 18");
}
// Ternary operator eg in Js
Top comments (1)
Perfect explanation for new coder