Learn Introductory JavaScript by Building a Pyramid Generator - Step 103

I delete the first two elements of the array, but the problem still remains unsolved. What am I doing wrong?

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 = numbers.unshift(5);
const shifted = numbers.shift() + numbers.shift();
console.log(shifted);
console.log(unshifted);
console.log(numbers);

// 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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 103

Hi and welcome to the forum.

Declare a shifted variable, assign it the result of calling .shift() on your numbers array, and print the variable.

const shifted = numbers.shift() + numbers.shift();

Very close, but you don’t need to add it to itself like this.

How? Then. I’ve tried averything.

Hello!
Along with the previous suggestion, I think this step requires the code be placed where it is above the unshifted code. The print looks good for the console.log.

Keep up good work.

Hi, i made that and it’s not working.

what is your code now please?

Please share your new code and make note of any errors or hints that are being displayed.

Hi pkdvalis,

This is very simple, take it one at a time. Start by declaring the shifted variable and the value of the variable should be numbers.shift() and finally console.log the variable you declared at first.

I hope this helps.

Please double check who you are writing to, @pkdvalis is not the person asking for help and doesn’t need an explanation

1 Like

Oh… That was a mistake it was suppose to be @AT22

Thank you all for the help. I’ve resolved following the steps of @Created-Unique. The last i’ve done was eliminate “+ numbers.shift()” and the unshifted variable. But… “const shifted = numbers.shift()” has to be above the “unshifted” line.
Captura de pantalla -2024-06-03 03-56-54

2 Likes