The Even Pulse
EasyAcc. 98.2%
+15 XP 5
The Rhythmic Counter
Loops are perfect for searching through ranges. By adjusting your loop variable so that it skips values, you can effortlessly focus only on the even pulses.
The Assignment
Your function receives a parameter named limit.
- Initialize a variable
numto 2. - Write a
whileloop that runs as long asnumis less than or equal tolimit. - Inside the loop:
- Print the current value of
num. - Step forward by 2 in each iteration.
- Print the current value of
01EXAMPLE 1
Input
limit = 10Output
2
4
6
8
10Explanation: Starts at 2, increments by 2 until 10.
02EXAMPLE 2
Input
limit = 5Output
2
4Explanation: Stops after 4 because 6 > 5.
Constraints
- Use a while loop.
- Output each number in a separate console log.
LoopsFundamentals
JavaScriptSystem handles I/O — write your function only
Loading...
4 Hidden
Input Arguments
limit10
Expected Output
2 4 6 8 10
Click RUN to test your solution