Skip to main content

if else statement in javascript and ternary operator

 here in this blog we are going to work with the if else and the ternary operator also


link for this example

link for example

replit ka login facebook see karo


let a =prompt("hey whats your age");

a= Number.parseInt(a);

if (a<0){alert("this is an invalid age")}

if (a<9){alert("you are a kid and dont even think of driving")}

if (a<18 && a>=9){alert("you can think of driving after 18")}

if (a>18){alert("you are eligible for driving")}

//here we are working with the ternary operator which satisfies the condition at the same line

console.log("you can",(a<18?"not drive":"drive"))

Comments