I can't figure out what is wrong with my code?

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

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

// Only change code below this line
let total = 0;
for (var i =0;i<myArr.length-1;i++){
total = total + i;

}

  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36

Challenge: Iterate Through an Array with a For Loop

Link to the challenge:

You didn’t finish asking your question. What is going on? What would you like help with?

Hi,
member a for loop clause is meant essentially three optional parts, in your case

  • var i = 0 - which defines at which position of you myArr the loop should start

  • i < myArr.length - 1: which determined at which position of your myArr the loop must end

*i++: which determine the step of each loop .

I’m suggesting you check at which position your for loop ends, and whether it’s where you intend it to end. you can do that by printing each index as the loop iterates through the array.

Const myArray = [1, 2, 3, 4, 5];

Let text = 0;
for( i = 0; i < myArray.length; i++)
text += I
Console.log(i);