Tell us what’s happening:
my code runs fine, but I don’t know how I will add a newline characters so as to pass the test
Your code so far
function pyramid(pattern, rows, boolean) {
if (!boolean) {
for (let j = rows; j > 0; j--) {
let spaces = ' '.repeat(rows - j);
let chars = pattern.repeat(2 * j - 1);
console.log(spaces + chars);
}
} else {
for (let i = 1; i <= rows; i++) {
let spaces = ' '.repeat(rows - i);
let chars = pattern.repeat(2 * i - 1);
console.log(spaces + chars);
}
}
}
console.log(pyramid("t", 5, true));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Challenge Information:
Build a Pyramid Generator - Build a Pyramid Generator