Learn Introductory JavaScript by Building a Pyramid Generator - Step 31

Tell us what’s happening:

JavaScript building pyramid generator / step 31
my for loop should increase “I” by 1 in each iteration , I am stuck here cant seem to get the solution

Your code so far

const character = "#";
const count = 8;
const rows = [];


// User Editable Region

let i = 1;
for (i = i + 1; i < count; i++) {
   
}

// User Editable Region

Your browser information:

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

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 31

Hello and welcome to the forum,

You declared i and then assigned the value of i+1 to the for loop variable. This causes your loop to start from 2, but you should iterate through each element in this loop. This means that the loop is passing over the first 2 elements.

For loop variables are:

  • The index of the iteration, declared inside the loop parentheses.
  • The condition of the loop, determining how long it will run.
  • The rule for how this iteration will work, typically increasing one by one with i++.

Two of this correct in your code. So, you have broken the first variable. It’s okay, you can reset this step or try to fix it again.

I hope this helps you.

thank you @ [0x74h51N] for the reply.
i have tried modifying it to the code bellow. but when i run it it gives the same error. but when i log it to the console it loops true

for (let i = 1; i < count; i = i + 1) {

}

Instructions for this step is:
For example, bees = bees + 3 would increase the value of bees by three.

Use that syntax to replace your "iteration" string with a reassignment statement that increases i by one.
Reset your challenge and just change the iteration.
@TRACETECH

Also, index numbers start at zero, so you should start your iteration index let i... from zero.

The ++ operator means i += 1, so you can just write i++.

Just try to reset it, and you will see the difference in your first variable in the for loop.