Pliz help! Iterate Through an Array with a For Loop

Tell us what’s happening:

Your code so far


// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

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

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

// Only change code below this line
var myTotal = 0;
for (var i = 0; i < myArr.length; i++) {
  myTotal += myArr[i];
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:63.0) Gecko/20100101 Firefox/63.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/iterate-through-an-array-with-a-for-loop/

You will have to change this variable’s name to total in order to pass the test.

Hope this helps.

thanx alot, it really helped

1 Like