Learn Introductory JavaScript by Building a Pyramid Generator - Step 98

Tell us what’s happening:


I was following all the steps exactly, doing all the searches the same, and still it asks “You must assign the result of your .unshift() call to your unshifted variable”

i dont know if i’m dumb, or the system have somenting with me.
(i’m brazilian so my inglish can not be so good, i dont like translator)

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 unshifted = 5;

// User Editable Region

let result = ""

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


Your browser information:

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

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 98

your call to unshift is not assigned to anything, you need to assign it to something

Right, now i know i am dumb actualy, even after i search everything about .unshift.

i still dont know what am i suposed to assign it.

on console the code runs perfectly.

btw, thanks for the help.

Assigning Example:

number = "string"

In the above example, I assigned the string to a variable name number.

hmmm understand.
but i did that in here, right ? :

const unshifted = 5;

This code says assign the number 5 to a varaible called unshifted

but that is not what the directions say to do

the directions say

and assign it the result of calling .unshift() on your numbers array.

To @ilenia 's point earlier, you were almost correct here

but the argument should be the number 5. not unshifted
Also, you never assigned it to your unshifted variable
that is why you are not passing the test

also the directions say to print your unshifted variable.

right now you are only printing numbers to the console

you need to fix that
you should also have a console statement for your unshifted variable

once you fix those things then the tests will pass

I’m still confused on this…

my code is:
const numbers = [1, 2, 3];

const unshifted = 5;




and I don’t see where I am going wrong

never mind I forgot that order matters

You have 5 lines but it is only 4 line, in your third, the number 5 get out and then third and fourth lines can be together in one.

1 Like

Guys, im back, after 10 days of giving up, and crying in my desk

i read 7 pages of reddit posts tryng to understand, and i just realyse how dumb am i

i put this on, and it gave me “4” on console, and i cant understand how it works, giving me “wrong result”

const numbers = [1, 2, 3];
const unshifted = numbers.unshift(5);

btw i pass, whithout understand kkkkkkkkkkkkkkkkkk (lmao in brasilian leng)

tks for the support guys!!

that seems to be exactly what unshift should return.
Read about unshift here:

Return value
The new length property of the object upon which the method was called.

After you use unshift there are 4 elements in the array, so it returns 4

HI @victorkauankauan

Here are some more examples on how unshift works

Open up the console and can click on the run button to see what is happening with the code.
It will better show what unshift returns

hope that helps