Tell us what’s happening:
Hi.
The console output seems correct but the tests are unsuccessful. Please guide me in figuring out what’s wrong.
Your code so far
function pyramid(char, count, inverted) {
let rows = [];
for (let i = 1; i <= count; i++) {
let spaces = " ".repeat(count - i);
let content = char.repeat(2 * i - 1);
rows.push(spaces + content + spaces);
}
let result;
if (inverted === false) {
result = rows.join("\n");
}
else {
result = rows.reverse().join("\n");
}
return result
}
console.log(pyramid("o", 4, false))
console.log(pyramid("p", 5, true))
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:146.0) Gecko/20100101 Firefox/146.0
Challenge Information:
Build a Pyramid Generator - Build a Pyramid Generator