Building a Pyramid Generator Step 101

Tell us what’s happening:

Hello. If I’m being completely honest I think I just forgot how to make an array. I thought it was done with these: {}

with that being said I thought my code was supposed to either be:

const numbers{1, 2, 3} = “”;
console.log(numbers);

or

const numbers = {1, 2, 3};
console.log(numbers);

clearly I’m forgetting some basic information I already learned and I’m going to go back over the whole lesson several times. But can someone give me a hint as to what I’m messing up? Thank you.

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};
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 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 101

Hi there and welcome to our community!

You use square brackets to denote an array. Curly brackets are used for objects.
When declaring a variable, you also need to remember the = sign.

1 Like

Haha why did I know it was going to be something so simple? Thank you my friend, my code has passed. I appreciate you answering so quickly.

1 Like