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.

  1. Initialize a variable num to 2.
  2. Write a while loop that runs as long as num is less than or equal to limit.
  3. Inside the loop:
    • Print the current value of num.
    • Step forward by 2 in each iteration.

01EXAMPLE 1

Inputlimit = 10
Output2 4 6 8 10

Explanation: Starts at 2, increments by 2 until 10.

02EXAMPLE 2

Inputlimit = 5
Output2 4

Explanation: Stops after 4 because 6 > 5.

Constraints

  • Use a while loop.
  • Output each number in a separate console log.
LoopsFundamentals
JavaScript
Loading...
4 Hidden

Input Arguments

limit10

Expected Output

2
4
6
8
10

Click RUN to test your solution