Build a Pyramid Generator - Build a Pyramid Generator

Tell us what’s happening:

I am getting the right pyramid shape but the JSON string is not what the tast is looking for. It looks like it needs to be joined with .join() but im having troubles where in my function am I able to implement that.
Please could someone provide me with an idea of where this might go? or if its something else im missing? thank you

Your code so far

function pyramid(pattern, rows, inverted) {
  let result = "";
  if (!inverted) {
    for (let i = 1; i <= rows; i++) {
      const row = " ".repeat(rows - i) + pattern.repeat(2 * i - 1) + " ".repeat(rows - i);
      result += "\n" + row;
    }
  }
  else {
    for (let i = rows; i >= 1; i--) {
      const row = " ".repeat(rows - i) + pattern.repeat(2 * i - 1) + " ".repeat(rows - i);
      result += "\n" + row;
    }
  }
  return result
}

console.log("Actual:   ", JSON.stringify(pyramid("o", 4, false)));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36

Challenge Information:

Build a Pyramid Generator - Build a Pyramid Generator

hello!

I don’t think,join() is required. Try starting with let result = “\n” instead of "”.

Also do you need the trailing spaces after the pattern in each row?

Thank you. it was kind of like you were saying. I added “\n” to the let result and removed the trailing spaces. But i also had to switch around the result += so that “\n” would come after the row.

thanks for input!