1//ternary operator syntax and usage:
2condition ? doThisIfTrue : doThisIfFalse
3
4//Simple example:
5let num1 = 1;
6let num2 = 2;
7num1 < num2 ? console.log("True") : console.log("False");
8// => "True"
9
10//Reverse it with greater than ( > ):
11num1 > num2 ? console.log("True") : console.log("False");
12// => "False"
1//ternary operator example:
2var isOpen = true; //try changing isOpen to false
3var welcomeMessage = isOpen ? "We are open, come on in." : "Sorry, we are closed.";
4
5
1const age = 19;
2if(age >= 18) {
3 const canVote = true;
4} else {
5 const canVote = false;
6}
7
8if (age>18) {
9 console.log("Mozete glasati")
10}