Learn Introductory JavaScript by Building a Pyramid Generator - Step 69

Tell us what’s happening:

I have searching the forums as suggested. Im lost first programming language so yeah lol. I added repeat to both empty strings as forum advice was but not sure about the error help. Do i need rowCount-rowNumber to and where kind confusing ill keep trying but help would be great

Your code so far

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


// User Editable Region

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

// 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/126.0.0.0 Safari/537.36 Edg/126.0.0.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 69

1 Like

when you add the .repeat() you have to add it directly after the character you want to repeat. You have left a space in between the " " and the dot. So remove those spaces.
Also repeat is a function that expects a number as an argument. You need to tell repeat how many times you want to repeat the space. So put the rowCount-rowNumber in the parenthesis.

1 Like

k I figured it out had rown number first instead of count also

1 Like

Call your repeat method, and add two arguments separated with a comma you should not put rowCount - rowNumber in your repeat method

" ".repeat(argument, argument)

Hope this helps

1 Like

This was helpful thanks