Learn Introductory JavaScript by Building a Pyramid Generator - Step 108

Tell us what’s happening:

i get this Error:
2. You should call .shift() on your numbers array.
3. You should assign the result of your .shift() call to your shifted variable.
// tests completed
i don’t know what is still missing or wrong in my code, because when i run it, it already shows me the first argument in the number array, which is [2], but something is wrong, so please help

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 = [2, 3]
const shifted = numbers.shift();
console.log(shifted);



// 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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 108

Reset the step and try it again.

Your code is fine, but you deleted some other lines following

1 Like

you were right, thanks a lot

1 Like