Learn Introductory JavaScript by Building a Pyramid Generator - Step 108

Tell us what’s happening:

I tried to call shift on my numbers array so much, what wrong

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

/*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

const numbers = [1, 2, 3];
const shifted = numbers.shift();
console.log(shifted)

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

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 108

Your code looks ok to me. Semi colon missing at the end of your console log but that shouldn’t have caused it to fail. Have you deleted some code that you should have already had after step 107? Perhaps reset to find out and do it again.

1 Like

Welcome to the forum @Wipedlife

Here is a comparison of the original code and your code.

The code in blue is the original code, the code in red is your code.
The code in magenta is the overlap.

image

You removed some code from the editor.

Please follow the advice from @a1legalfreelance and reset the challenge.
Then add the code asked for in the instructions, without removing or altering any of the other code.

Happy coding

2 Likes