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.
- Calculate the sum of numbers from 1 to
max. - If the current number is even (divisible by 2), use
continueto skip it. - Return the sum of only the odd numbers.
Constraints
FundamentalsLoops
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
max10
Expected Output
25
Click RUN to test your solution