The Odd Sum Only

Medium+20 XP

Mission Briefing

The data stream is filled with corrupted, even-numbered packets. You must sum the incoming values but explicitly skip the corrupted ones to avoid system failure.

The Concept: The Continue Keyword

While break stops a loop entirely, the continue keyword simply skips the rest of the current iteration and immediately jumps back to the top to evaluate the next loop.

The Objective

Your function receives a parameter max.

  1. Calculate the sum of numbers from 1 to max.
  2. If the current number is even (divisible by 2), use continue to skip it.
  3. Return the sum of only the odd numbers.

Constraints

    FundamentalsLoops
    JavaScript
    Loading...
    3 Hidden

    Input Arguments

    max10

    Expected Output

    25

    Click RUN to test your solution