1
2
3
4
5
6
7
8
9
10
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.
0,1,2,3,4,5,6,7,8,9
0
0
0
0
Type the ternary operator. | ? | \? | |
? is the ________ operator. | ternary | ternary | |
What character replaces else in the shorthand version? | : | : | |
In the following code, feedback is "yes" if answer === "tail", no if it's something else. Fill in the blank. | let feedback = answer === "tail" ? ____________________; | "yes" : "no" | •yes•:•no•;? |
The statement is testing whether answer is "tail". Fill in the blank. | let feedback __________________ "yes" : "no"; | = answer === "tail" ? | =answer===•tail•\? |
Rewrite the following code using the shortcut. | let feedback; if (answer === "tail") { feedback = "yes";} else { feedback = "no"; } |
let feedback = answer === "tail" ? "yes" : "no"; | letfeedback=answer===•tail•\?•yes•:•no•; |
Assign 0 to x if y === 0. Otherwise assign 1 to x. x wasn't previously declared. Use the shortcut. | let x = y === 0 ? 0 : 1; | letx=y===0\?0:1; | |
Write a shortcut to if...else using nothing but variables. No numbers, no strings. Make up everything. | let x = y === z ? a : b; | let[a-z_$][a-zA-Z0-9_$]*=[a-z_$][a-zA-Z0-9_$]*===[a-z_$][a-zA-Z0-9_$]*\?[a-z_$][a-zA-Z0-9_$]*:[a-z_$][a-zA-Z0-9_$]*; | |
|
|||
|