What did I do right?!

Tell us what’s happening:
Describe your issue in detail here.
The code I put wasn’t making sense. Honestly, I was just hopelessly trying anything, but then it accepted it as correct. To better understand where I went right I went to the forum and I don’t even see my code anywhere :sweat_smile: Could someone tell me what I did? Thanks!

**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+= 20){

**Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36

Challenge: Iterate Through an Array with a For Loop

Link to the challenge:

That is not right. That’s very wrong in a way that is accidentally reaching the target number.

1 Like

HI @kishou !

Welcome to the forum!

I would suggest resetting the lesson.

Here are the first part of the instructions.
Declare and initialize a variable total to 0 .

Don’t declare that variable in the for loop.

Then create a for loop.
It should follow the same structure as the example they gave you.

Then inside the for loop, instead of using console.log like the example did you will need to add the value of each element of the myArr array to total .

Give that a try and let us know if you need extra help. :slight_smile:

1 Like

Sounds about right. Thanks!

This helped a bunch! Thanks for your help!