Build a Pyramid Generator - Build a Pyramid Generator

Tell us what’s happening:

my code outputs a pyramid correctly, based on bool, but I still can’t pass

Your code so far

function pyramid(str, int, bool){
  let result = "";
  for (let i=1; i<int+int; i+=2){
    let spaces = (int + int - 1 - i) / 2;
    let rows = " ".repeat(spaces)+str.repeat(i);
    result += rows + "\n";
  }if(bool === false){
      return result
  }if(bool === true){ 
    return result.split("\n").reverse().join("\n")
    }
}
console.log(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/143.0.0.0 Safari/537.36

Challenge Information:

Build a Pyramid Generator - Build a Pyramid Generator

Welcome to the forum @QuanMarquis!

  1. The pyramid should start and end with a newline character.

Try this to make your newlines visible.

console.log(pyramid("o", 4, false).replaceAll("\n","\\n"))

Then, compare your output with the tests.