Learn Introductory JavaScript by Building a Pyramid Generator - Step 69

Tell us what’s happening:

Step 69 test questions:

Update your blank space strings to be repeated – rowCount - rowNumber – times. I think this is confusing :face_with_spiral_eyes:

Your code so far

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


// User Editable Region

function padRow(rowNumber, rowCount) {
  return "character.repeat(rowCount - rowNumber)" + character.repeat(rowNumber) + " 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 + row + "\n";
}

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/131.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 69

you don’t have space strings anymore now

like you did with character, you can use methods directly on literal strings

"hi".repeat(3); // hihihi

return “character”.repeat(rowCount - rowNumber) + character.repeat(rowNumber) + “character”.repeat(rowCount - rowNumber); :thinking:

where are the space strings? can you use your own words to expalin your doubts please?

It looks like you’re getting confused by using a literal string to represent a space. Your updated code would repeat the word “character” rather than a space. You can test by looking at what your code is returning in the console.

1 Like