# Learn Introductory JavaScript by Building a Pyramid Generator - Step 99

### Tell us what’s happening:

On Step 99, I wrote:
const numbers = [1, 2, 3];

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

const shifted = numbers.shift();
console.log(shifted);

The systemon the console showed 4 (the correct answer for unshifted) and 5(right answer for shifted) but said:
“You should call .shift() on your numbers array.
You should assign the result of your .shift() call to your shifted variable.”

``````const character = "#";
const count = 8;
const rows = [];

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

/*while (rows.length < count) {
}*/

/*for (let i = count; i > 0; i--) {
}*/

// User Editable Region

// User Editable Region

let result = ""

for (const row of rows) {
result = result + "\n" + row;
}

console.log(result);

//Step 99

const numbers = [1, 2, 3];

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

const shifted = numbers.shift();
console.log(shifted);
``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36`

### Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 99

Here was the original code

``````const numbers = [1, 2, 3];

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

``````const numbers = [1, 2, 3];

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

So why does order matter?
Because when you use these methods of push, pop, shift, etc it mutates the original array.

To better understand,
here is what the correct result produces in the console.
I added an extra console statement so you can better see the difference.

``````This is the original numbers array [ 1, 2, 3 ]
This is the result of the shifted variable 1
This is the updated array after shift was used [ 2, 3 ]
This is the result of unshift 3
This is the updated array after unshift was used [ 5, 2, 3 ]
``````

Pay close attention to the difference in the arrays

``````this is the original numbers array [ 1, 2, 3 ]
result of unshift 4
this is the mutated array after unshift [ 5, 1, 2, 3 ]
Result of shift 5
this is the mutated array after shift [ 1, 2, 3 ]
``````

Hope that helps

1 Like

There is a blank line, reset the lesson, you will see a blank line that where u are supposed to work on this is the solution though
const numbers = [1, 2, 3];

const shifted = numbers.shift();

console.log(shifted);

const unshifted = numbers.unshift(5);

console.log(unshifted);

console.log(numbers);

@Qudus and @Jwilkins - thank you. I think I see that my error was to do unshift first? I appreciate your help!