Build a Pyramid Generator - Build a Pyramid Generator

Tell us what’s happening:

I need help, remaining 2 steps to complete it I don’t know what’s wrong

Your code so far

function pyramid(char,height,boolean){
console.log()
 if(boolean){
  for(let i = height; i >= 1; i--){
     console.log(" ".repeat(height-i) + char.repeat(2*i - 1))
    }
 }else{
  for(let i = 1; i <= height; i++){
    console.log(" ".repeat(height-i) + char.repeat(2*i - 1) )
    }   
  }
console.log()
}  

pyramid("p",5,true)
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/136.0.0.0 Safari/537.36 Edg/136.0.0.0

Challenge Information:

Build a Pyramid Generator - Build a Pyramid Generator

what is your function returning?

well, no
do you see a return statement somewhere ? your function is returning undefined

no but my function is returning the two pyramids but step 3 and step 4 isn’t going

return is a specific keyword, and it does not relate to console.log() which is what your function is logging to the console.

If you don’t use the return keyword then your function will return undefined.

The pyramid function should return a string

Your function need to return a single string (as opposed to logging anything to the console).

If you want to see what your function returns, you can call it like this:

console.log(pyramid("p",5,true))