jeudi 5 décembre 2019

How to code else if in short if statement?

For example, I have code with short if statement and how can I code else if in this code?

 var age = 16;

 age > 18 ? console.log("> 18") : console.log("< 18");

That would work like this code

var age = 16;
if (age > 18){
    console.log("> 18");
}else if(age == 18){
    console.log("= 18");
}else{
    console.log("< 18");
}

Aucun commentaire:

Enregistrer un commentaire