if else if condition ternary operator js code example
Example 1: if statement javascript one line ?
(lemons) ? alert("please give me a lemonade") : alert("then give me a beer");
Example 2: javascript question mark
//This is what is called a 'Conditional operator'
let result = condition ? value1 : value2
// ^^ ^^ ^^
let result = 1 == 2 ? "YES" : "NO!"
console.log(result) //output: "NO!"
//Basically a short form of an if-else statment