Build a Pyramid Generator - Build a Pyramid Generator

Tell us what’s happening:

no idea whats wrong. the output seems to be correct

Your code so far

function pyramid(string, rows, bool) {
  let result = "";

  for (let i = 0; i < rows; i++) {
    if (bool === true) {
      let spaces = " ".repeat(rows - i - 1);
      let chars = string.repeat(i * 2 + 1);
      result += spaces + chars + "\n";
    } else {
      let spaces = " ".repeat(i);
      let chars = string.repeat((rows - i - 1) * 2 + 1);
      result += spaces + chars + "\n";
    }
  }

  return result;
}
console.log(pyramid("o", 4, true))

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

Welcome to the forum @MuaZah

Is your pyramid the right way round?

Happy coding