Build a Pyramid Generator - Build a Pyramid Generator

Tell us what’s happening:

Code codes seems to be working correctly. I tested it with multiple rows. It has an empty line before and after the pyramid. Why am I not able to pass?

Your code so far

let pyramid = (str, int, bool)=>{
  console.log("");
  if (!bool){
    for (let i=0; i<int; i++){
        let spaces = " ".repeat(int - i - 1);
        let repeat = str.repeat(2*i+1)
        console.log(spaces+repeat)
      }
  }else{
    for (let i=int-1;i>=0; i--){
      let spaces = " ".repeat(int - i-1);
      let repeat = str.repeat(2*i+1)
      console.log(spaces+repeat)
    }
  }
  console.log("");
}
pyramid("o",4,true);
pyramid("p",5,false);

Your browser information:

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

Challenge Information:

Build a Pyramid Generator - Build a Pyramid Generator
https://www.freecodecamp.org/learn/full-stack-developer/lab-pyramid-generator/lab-pyramid-generator

I don’t see where you are returning anything?

1 Like

I have a question. What is your function returning?

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.