Skip Iteration

MediumAcc. 91.2%
+25 XP 10

Selective Scanning

Your task is to sum every second element (index 0, 2, 4...) in the array.

The Assignment

Your function receives an array data.

  1. Use a loop where the index incrementer is i += 2.
  2. Sum the elements at these indices.
  3. Print the final sum.

01EXAMPLE 1

Input[1, 10, 2, 20]
Output3

Explanation: 1 + 2 = 3.

Constraints

  • Stop before the end of the array.
ArraysLoops
JavaScript
Loading...
2 Hidden

Input Arguments

data[1,10,2,20]

Expected Output

3

Click RUN to test your solution