JavaScript Conditionals Flashcards

1
Q

What does a Ternary Operator do?

A

It simplifies an if…else statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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!’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Do you need a semicolon after an else statement?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Do you need a semicolon after an else if statement?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Do you need a semicolon after an if statement?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly