Learn Introductory JavaScript by Building a Pyramid Generator - Step 117

Tell us what’s happening:

This is my code:
let character = “!”;
let count = 10;
let inverted = false;

It keeps stating that I should “set character to “!””.

Where am I going wrong?

Would appreciate the direction and assistance.
Cheers

Your code so far


// User Editable Region

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

// User Editable Region


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

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/126.0.0.0 Safari/537.36 Edg/126.0.0.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 117

1 Like

Hello,
You created a whole new variable called character and assigned ! to it while what you should have done is to change the already defined character variable defined using the const keyword, same thing goes for both count and inverted variables, just change the values of the existing ones and do not create new ones
I hope this helps.

1 Like

okay thanks. It worked. Much appreciated.

2 Likes

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