Learn Introductory JavaScript by Building a Pyramid Generator - Step 99

Tell us what’s happening:

reversed pyramid is created by me but still the code isn’t passing.

Your code so far


// User Editable Region

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

function padRow(rowNumber) {
  const numSpaces = count - rowNumber; // Calculate leading spaces
  const numChars = 2 * rowNumber - 1;  // Calculate number of characters
  return " ".repeat(numSpaces) + character.repeat(numChars);
}

// Generate rows for the inverted pyramid
for (let i = count; i >= 1; i--) {
  rows.push(padRow(i));
}

// Print the rows
let result = rows.join("\n");
console.log(result);

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 99

hi there, your code doesn’t seem to match the original code given, so I’m not sure what changes you made.

Can you click reset, and paste the new code in without deleting anything that is already there please?

edit: note that the for loop they are asking for should not have any content except what they specifically said should be written.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.