Basic JavaScript - Iterate Through an Array with a For Loop

Tell us what’s happening:
I’m not sure how to get the total to equal 20

Your code so far

// Setup
const myArr = [2, 3, 4, 5, 6];

// Only change code below this line

for (let total = 0; total < myArr.length; total++) {
console.log(myArr[total]);
}

Challenge: Basic JavaScript - Iterate Through an Array with a For Loop

Link to the challenge:

The variable total should be used for adding each value in the array, not as a counter for the for loop. So you’ll want to declare total before the for loop. Then inside of the for loop you will add each value in the array to total.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.