/Conditional Statements & Loops
Concept Detail

Conditional Statements & Loops

Difficulty: easy

Overview


if/else, switch, and the ternary operator (?:) control branching. The nullish coalescing operator (??) returns the right operand only when the left is null or undefined — unlike || which triggers on any falsy value. for, while, and do-while are the primary loops. for...of iterates over iterable values; for...in iterates over enumerable property keys.

Practice Linked Questions


medium

Q1. What does the nullish coalescing operator (`??`) return?


Select one answer before revealing.

easy

Q2. What is the output of the following code? ```js let x = 5; console.log(x > 3 ? "big" : "small"); ```


Select one answer before revealing.

medium

Q3. Which of the following values are falsy in JavaScript? (More than one answer may be correct.)


Select one answer before revealing.

easy

Q4. What is the output? ```js let i = 0; while (i < 3) { i++; } console.log(i); ```


Select one answer before revealing.

medium

Q5. What is the difference between `for...of` and `for...in`?


Select one answer before revealing.

medium

Q6. What does the logical OR (`||`) operator return?


Select one answer before revealing.