Learn Introductory JavaScript by Building a Pyramid Generator - Step 70

Tell us what’s happening:

Your function should pass 2 * rowNumber - 1 to your .repeat() call.

function printPattern(rows) {
for (let row = 1; row <= rows; row++) {
// Directly use 2 * row - 1 for the number of hashes
console.log(" ".repeat(rows - row) + “#”.repeat(2 * row - 1));
}
}

printPattern(3);

I do not understand what I’m doing here and I’m trying to figure everything out.

Your code so far

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


// User Editable Region

function printPattern(rows) {
  for (let row = 1; row <= rows; row++) {
    // Directly use 2 * row - 1 for the number of hashes
    console.log(" ".repeat(rows - row) + "#".repeat(2 * row - 1));
  }
}

printPattern(3);


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

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 70

I don’t understand what I’m doing here and the code is not getting through the console.

I need some assistance as to what I need to do so that way it gets through.

Hi @lsrms3977

You updated the function definition, which you were not asked to do.
For this step you need to modify the repeat() method for the character variable.

Happy coding

Is there a correct way to write it?

There are different ways to write code that produces similar results.
For the practice projects the tests are looking for specific code.

First reset the step to restore the seed code.
Then locate the character variable and update the method.