Build a Pyramid Generator - Build a Pyramid Generator

Tell us what’s happening:

Test 3 and 4 does not pass. What am I doing wrong?

Your code so far

const pattern = "o";
const rows = 4;
const isTrue = false;

function pyramid(pattern, rows, isTrue){
  let space = ' ';
  let result;
  if(isTrue === false){
  for(let i = 1; i <= rows; i++){
    console.log(space.repeat(rows-i) + pattern.repeat(i * 2 - 1)); 
    }
  }else {
    for(let i = 5; i > 0; i--){
    console.log(space.repeat(rows-i) + pattern.repeat(i * 2 - 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/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

hi there, welcome to the forum

For this lab, please note the following requirement:

The pyramid function should return a string

I don’t see a return statement anywhere in your code?

Thank you! I had missed that, and had to figure out how to get the return result to show what I wanted (simply returning the result inside the loop only gave me the last iteration of the loop).
All done now, and moving on to the next step. Thank you for the warm welcome :slight_smile: