javascript abbreviated if else code example
Example 1: shorthand if statment in js
isLoggedIn ? "Logout" : "Login";
Example 2: javascript if shorthand
condition ? doThisIfTrue : doThisIfFalse
1 > 2 ? console.log(true) : console.log(false)
// returns false
Example 3: javascript if else
var age=20;
if (age < 18) {
console.log("underage");
} else {
console.log("let em in!");
}
Example 4: javascript if elseif
if (condition) {
} else if (other_condition) {
} else {
}