Plz , help me ... i got hang on this ...help needed

Plz , help me ... i got hang on this ...help needed
0

#1

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 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/61.0.

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


#2

You’re almost there! The only thing left is semantic.

The challenge reads:

Declare and initialize a variable total to 0. Use a for loop to add the value of each element of the myArr array to total.

Compare what it calls its variables to what you called yours, then you’re solid!


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