Learn Introductory JavaScript by Building a Pyramid Generator - Step 46

Tell us what’s happening:

Just a thought, instead of adding 1 to i inside the for of loop.
We can alter the loop itself to show case as below

const character = “#”;
const count = 8;
const row = ;
-------> for(let i = 1; i<= count; i=i+1){ <-------
rows.push(character.repeat(i));
}

Your code so far

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


// User Editable Region

for (let i = 1; i <= count; i = i + 1) {
  rows.push(character.repeat(i))
}

// User Editable Region


let result = ""

for (const row of rows) {
  result = result + row + "\n";
}

console.log(result);

Your browser information:

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

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 46

Hello, you just touched on a subject I learned about for loops.

For loops are short-hand while loops in numerical contexts.

x = 0;
while (x < 5) {
  x++;
}

you are right, it must be that programmers are used to start from 0