JavaScript Conditionals Flashcards
1
Q
What does a Ternary Operator do?
A
It simplifies an if…else statement
2
Q
Write out an example of a Ternary Operator
A
let isNightTime = true;
if (isNightTime) { console.log('Turn on the lights!'); } else { console.log('Turn off the lights!'); }
isNightTime ? console.log(‘Turn on the lights!’) : console.log(‘Turn off the lights!’);
3
Q
Do you need a semicolon after an else statement?
A
No
4
Q
Do you need a semicolon after an else if statement?
A
Yes
5
Q
Do you need a semicolon after an if statement?
A
Yes