Learn Introductory JavaScript by Building a Pyramid Generator - Step 69

Tell us what’s happening:

Hey friends

I have tried many different ways to tackle this

erasing character and putting in " ".repeat
making a new " ".repeat above the return line
putting a new .repeat in the brackets of the return line

I understand why some of my tries didn’t work I was desperate on some of them. This is the latest try. I have read the answers to another question asked about this and have no idea if I need another .repeat notation or reform this one somehow. I’m lost

thanks in advance.

Your code so far

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


// User Editable Region

function padRow(rowNumber, rowCount) {
  return character + " " + " ".repeat(rowCount - rowNumber);
}

// User Editable Region


for (let i = 0; i < count; i = i + 1) {
  rows.push(padRow(i + 1, count));
}

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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 69

if you reset the step you will see that this is the starting return statement

return " " + character.repeat(rowNumber) + " ";

to this you need to add the feature that the number of spaces is calculated dinamically, to do that you need to add the repeat function to the two space strings so that the number of spaces is determined by the repeat function

1 Like

Will I then end up with multiple .repeat functions or will I use the original one?

Never mind I got it! you all rock thanks

1 Like