Learn Introductory JavaScript by Building a Pyramid Generator - Step 117

Tell us what’s happening:

  1. You should remove code that was commented out by multi-line comments. this error persist on the code but i didn’t found where multi-line comments in my code

Your code so far

const character = "#";
const count = 8;
const rows = [];
let inverted = true;

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


// User Editable Region

for (let i = 1; i <= count; i++) {
  if (inverted) {
    rows.unshift(padRow(i, count));
  } else {
    rows.push(padRow(i, count));
  }
}

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

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

// 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; rv:135.0) Gecko/20100101 Firefox/135.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 117

Please “Reset” and try again. You were to remove all commented out code, but instead you seem to have removed just the /* */.

2 Likes

Hi there. I tried the challenge step and it’s also isn’t passing the test on my end. Didn’t know what’s the problem is.

These comments aren’t in the challenge step.

Hi,
The above lines of code were originally commented out, and you were asked to remove them all. As suggested, you should reset the step and try removing the comments.
Good luck!

1 Like

I will reset the step and make sure that all the comments made are properly removed. Appreciate guidance - cleaner code is always a target. It must have happened once!

thank you it works now

i’m still getting an error even after I have removed the comments const character = “#”;
const count = 8;
const rows = ;
let inverted = true;

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

for (let i = 1; i <= count; i++) {
if (inverted) {
rows.unshift(padRow(i, count));
} else {
rows.push(padRow(i, count));
}
}

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

for (let i = count; i > 0; i–) {
rows.push(padRow(i, count));
}

let result = “”

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

console.log(result);

Please can you open a new topic for your query on this step.

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge. This button only appears if you have tried to submit an answer at least three times.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.