Learn Introductory JavaScript by Building a Pyramid Generator - Step 115

Tell us what’s happening:

You should pass a padRow() call as the argument for your .unshift() method.

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

// TODO: use a different type of loop

// User Editable Region

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


// User Editable Region


/*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 + "\n" + row;
}

console.log(result);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 115

Hi @Shooki

The hint messages are wrong.

Please reset the step, and try again.

For this step, use the .push method.

Here is the correct error message.

You should call the .push() method of rows in your else block.

Happy coding

still the same

You should pass a

padRow()

call as the argument for your

.unshift()

method. You should pass

I

as the first argument to your

padRow()

call. You should pass

count

as the second argument to your

padRow()

call.

Hi @Shooki

Reset the step then press the Check Your Code button to see the correct error message.

I still get this after the “check your code”
You should pass a padRow() call as the argument for your .unshift() method.
the new code
for (let i = 1; i <= count; i++) {
if (inverted) {
rows.unshift(padRow(i, count));
}
else {rows.push(rows);
}
}

1 Like

When I empty the else block I receive this hint message:

You should call the .push() method of rows in your else block.

1 Like

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