Iterate Through an Array with a For Loop - problem

Iterate Through an Array with a For Loop - problem
0

#1

Hi, I’m having trouble with this exercise. My code is like that:

var myArr = [ 2, 3, 4, 5, 6];
var myTotal = 0;

for (var i = 0; i < myArr.length; i++) {
myTotal += myArr[i];
}

Is still returning the error that total should equal 20 and declared and initialized to 0.

Any help?


#2

You should

Declare and initialize a variable total

not myTotal


#3

Nothing wrong, but the challenge wants you to use total instead of myTotal


#4

yeah, that was the whole problem lol, thanks