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.

  1. Start a for loop that counts from 1 to 100.
  2. If the current number is strictly greater than limit, use break to exit the loop.
  3. Return how many numbers were successfully processed (which should be equal to the limit!).

Constraints

    FundamentalsLoops
    JavaScript
    Loading...
    3 Hidden

    Input Arguments

    limit5

    Expected Output

    5

    Click RUN to test your solution