Build a Pyramid Generator - Build a Pyramid Generator

Tell us what’s happening:

giving correct result but not passing. Can someone please help?

Your code so far

const pyramid = (str, num, bool)=> {
  if (bool === false){
    for(let i = 1; i <= num; i++){
      console.log(' '.repeat(num - i) + str.repeat(2 * i - 1))
    }
  } else {
    for (let i = num; i >= 1; i--){
      console.log(' '.repeat(num - i) + str.repeat(2 * i - 1))
    }
  }
}

pyramid("p", 5, true)

Your browser information:

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

Challenge Information:

Build a Pyramid Generator - Build a Pyramid Generator

Console logging is not the same thing as returning a string.

1 Like