Build a Pyramid Generator - Build a Pyramid Generator

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

Try adding this code to compare actual to expected:

console.log("Actual:   ", JSON.stringify(pyramid("o", 4, false)));
console.log("Expected: ", JSON.stringify("\n   o\n  ooo\n ooooo\nooooooo\n"));
console.log("Actual:   ", JSON.stringify(pyramid("p", 5, true)));
console.log("Expected: ", JSON.stringify("\nppppppppp\n ppppppp\n  ppppp\n   ppp\n    p\n"));

Hi,
I maanaged to figure it out. Thank you for your comment!