The Safety Switch
Medium+20 XP
Mission Briefing
The reactor is overheating! You must write a safety sequence that stops the counting loop immediately if a critical limit is reached.
The Concept: The Break Keyword
Sometimes a loop needs to be aborted before its natural condition finishes. The break keyword immediately stops and completely exits the loop it is inside.
The Objective
Your function receives a critical limit.
- Start a
forloop that counts from 1 to 100. - If the current number is strictly greater than
limit, usebreakto exit the loop. - Return how many numbers were successfully processed (which should be equal to the
limit!).
Constraints
FundamentalsLoops
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
limit5
Expected Output
5
Click RUN to test your solution