Learn Introductory JavaScript by Building a Pyramid Generator - Step 89

Tell us what’s happening:

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

above is my code , i am on step 89 , what comment do i need to write in the loop body , it asked write a multi line comment in loop body
please can someone help?

Your code so far

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));
}*/


// User Editable Region


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

// User Editable Region


let result = ""

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

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

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 89

you don’t need to write anything in the loop

Use a multi-line comment to comment out your while loop.

You need to comment out the loop, that means surrounding it with the symbols that start and end a comment

what is the meaning of comment out the loop ?

Commented code is not executed. This means that if you want to try a different approach to a problem by writing it in a different way, you can comment out a section of code so that it doesn’t run.

This can help in troubleshooting also. Try it out.

Check out this article for more about commenting:

Does this help?
Keep up the good progress!

Happy Coding! :slightly_smiling_face:

sorry no i still stuck there.

Ok, your code below has a TODO comment and below that the for loop is commented out with the /* and */. The TODO comment is a note to the programmer and is a special type of comment not executed by the computer.

The comment characters surrounding the for loop mean that the computer should ignore that code. In other words, the for loop will not run.

Does that help?

1 Like

great! I understood,
thank you for u r guidance

1 Like