Learn Introductory JavaScript by Building a Pyramid Generator - Step 108

Tell us what’s happening:

it keep show me this : You should call .shift() on your numbers array

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

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/138.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 108

I would reset the step and only add code (don’t delete anything unless the instructions ask you to).

i reset it and it still told me to call . shift() on numbers array

Did you reset the code, DELETE NOTHING, and then add the two lines requested? Please post your updated code.

const numbers = [1, 2, 3];

const shifted = numbers.shift();

console.log(shifted);

console.log(numbers);

You deleted lines of code that were there. You absolutely must not do this. Reset the code again and DELETE ABSOLUTELY NOTHING.

const numbers = [1, 2, 3];

const unshifted = numbers.unshift(5);

console.log(unshifted);

console.log(numbers); this is the code after reset

Now type the two lines the instructions ask for. Delete nothing that is already there.

const numbers = [1, 2, 3];

const shifted = numbers.shift(5);

console.log(shifted);

console.log(numbers); like this

You just deleted two lines of code.

Why did you delete these two lines?

it told to use shift

Yes. You should use shift. You should also not remove any of the old code. Do not use the delete key in any way at all. Seriously. Type out the full new two lines the instructions ask you to add.

1 Like

thanks brother it work const numbers = [1, 2, 3];

const shifted=numbers.shift();
const unshifted = numbers.unshift(5);
console.log(shifted);
console.log(unshifted);
console.log(numbers);

1 Like

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