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.