Build a Pyramid Generator - Build a Pyramid Generator

Tell us what’s happening:

Stuck pretty good on this one… I feel like it should be passing… when the pyramid is right side up I have the \n at the top giving the pyramid an empty top row. When the pyramid is inverted I have the new top line to have a \n, again making the top row blank. Could be something very obvious… Please help

Your code so far

function pyramid(symb, height, tOrF) {
  if (tOrF === false) {
    for (let i = 0; i <= height; i++) {
      if (i === 0) {
        let topRow = "\n";
        console.log(topRow);
      } else {
        const spaces = " ".repeat(height - i);
        const content = symb.repeat(2 * i - 1);
        let row = spaces + content + "\n";
        console.log(row);
      }
    }
  } else if (tOrF === true) {
        let topLine = height + 1;
    for (let i = topLine; i >= 1; i--) {
      if (i === topLine) {
        let topRow = "\n";
        console.log(topRow);
      } else {
        const spaces = " ".repeat(height - i);
        const content = symb.repeat(2 * i - 1);
        let row = spaces + content + "\n";
        console.log(row);
      }
    }
  }
}

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

  1. The pyramid function should return a string in which the pattern character is repeated and arranged to form a pyramid having the vertex facing upwards when the third argument is false.

What is your function returning?

My code appears to be correct, just does not pass. I get a pyramid when the third argument is false and an inverted pyramid when it is true..

Yes. Please read again this snippet from the instructions:

The pyramid function should return a string

Again, what does your function return?

make sure you understand between logging a value and returning a value