Question Bank

JavaScript Control Flow and Conditional Quiz

Difficulty: Easy

Read JavaScript's small but treacherous control-flow rules: switch fall-through, ASI biting return statements, and short-circuit logical chains.

Question Bank
/

JavaScript Control Flow and Conditional Quiz

JavaScript Control Flow and Conditional Quiz

Read JavaScript's small but treacherous control-flow rules: switch fall-through, ASI biting return statements, and short-circuit logical chains.

Question Bank
Easy
JavaScript
3 questions
quiz
conditionals
loops
fundamentals

753 views

22

Implement getRange(n) with a single switch so that 1-3 -> 'Low', 4-6 -> 'Mid', 7-9 -> 'High', anything else -> 'Not in range!'. Use case fall-through.

Examples

Example 1:

Input: getRange(6), getRange(8), getRange(12)
Output: 'Mid', 'High', 'Not in range!'
Explanation: Stacking case labels without a `break` lets multiple values share a single block. The `default` clause catches everything else.