Learn Introductory JavaScript by Building a Pyramid Generator - Step 95

Tell us what’s happening:

This problem i have reset and follwed the instructions but i am not sure what i am doing wrong in this one

Your code so far


// User Editable Region

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

function padRow(rowNumber, rowCount) {
  return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber);
}
for (let i = count; i > 0; i--) {
  rows.push(padRow(i, count));
}

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

// 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/125.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 95

Don’t fill in the last part of the loop yet, the increment. You can leave that as false. Instructions only ask for the condition.

ok can I have some help with that

const character = "#";

const count = 8;

const rows = [];

function padRow(rowNumber, rowCount) {

return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber);

}

// TODO: use a different type of loop

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

rows.push(padRow(i, count));

}*/

/*while (rows.length < count) {

rows.push(padRow(rows.length + 1, count));

}*/

for (let i = count; false; false) {

}

let result = ""

for (const row of rows) {

result = result + "\n" + row;

}

console.log(result);
for (let i = count; false; false)
for (let i = count; condition; increment)

Fill in the condition, as you did. Leave the increment false.

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

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

function padRow(rowNumber, rowCount) {
  return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber);
}

// TODO: use a different type of loop
/*for (let i = 1; i <= count; i++) {
  rows.push(padRow(i, count));
}*/

/*while (rows.length < count) {
  rows.push(padRow(rows.length + 1, count));
}*/

for (let i = count; false; false) {

}

let result = ""

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

console.log(result);

you condition statement currently says “false” so your loop will never run.
The step wants you to change that so your loop can run under certain conditions (described in the step).
Please try again.

Read what I wrote.

Don’t just copy the code, I’m not going to give you the solution.

for (let i = count; false; false) {

for (let i >0; i–)

}

You were closer the first time. This is very wrong…

for (let i = count; false; false)

This is the original code. Just change the first “false”. Do not change the second “false”

It’s a lot like this step, isn’t it?
https://forum.freecodecamp.org/t/learn-introductory-javascript-by-building-a-pyramid-generator-step-28/692463/

for (let i = count;i >0; i-- false); {
rows.push(padRow(i, count))
} @pkdvalis

It looks like you are struggling with understanding how for loops work so I will suggest that you read this page which may help you further