1const x = true;
2var result = x === true ? "passed" : "failed";
3
4//Explanation
5//var 1.result = 2.x 3.=== 4.true 5.? 6."passed" 7.: 8."failed";
6//1.result
7//2.left side of if statement
8//3.if statement operator
9//4.right side of if statement
10//5.shorthand then operator
11//6.if true the result will be "passed"
12//7.shorthand else operator
13//8.if false the result will be "failed"
1let startingNum = startingNum ? otherNum : 1
2// can be expressed as
3let startingNum = otherNum || 1
4
5// Another scenario not covered here is if you want the value
6// to return false when not matched.
7//The JavaScript shorthandfor this is:
8let startingNum = startingNum ? otherNum : 0
9// But it can be expressed as
10let startingNum = startingNum && otherNum