Tell us what’s happening:
Stuck pretty good on this one… I feel like it should be passing… when the pyramid is right side up I have the \n at the top giving the pyramid an empty top row. When the pyramid is inverted I have the new top line to have a \n, again making the top row blank. Could be something very obvious… Please help
Your code so far
function pyramid(symb, height, tOrF) {
if (tOrF === false) {
for (let i = 0; i <= height; i++) {
if (i === 0) {
let topRow = "\n";
console.log(topRow);
} else {
const spaces = " ".repeat(height - i);
const content = symb.repeat(2 * i - 1);
let row = spaces + content + "\n";
console.log(row);
}
}
} else if (tOrF === true) {
let topLine = height + 1;
for (let i = topLine; i >= 1; i--) {
if (i === topLine) {
let topRow = "\n";
console.log(topRow);
} else {
const spaces = " ".repeat(height - i);
const content = symb.repeat(2 * i - 1);
let row = spaces + content + "\n";
console.log(row);
}
}
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Challenge Information:
Build a Pyramid Generator - Build a Pyramid Generator