Build a Pyramid Generator - Build a Pyramid Generator

Tell us what’s happening:

je ne reussi pas a retourner mon resultat normalement

Your code so far

function pyramid(motif,num,bool){
  let repeat
  let result
  if(bool===false){
    for(let i=0;i<num;i++){
      result=" ".repeat(num-i-1)+motif.repeat(2*i+1)+" ".repeat(num-i-1)
      console.log(result)
    }
  }else if(bool===true){
    for(let i=0;i<num;i++){
      result=" ".repeat(i)+motif.repeat(2 * (num - i) - 1)+" ".repeat(i)
      console.log(result)
    }
  }
  return result
}    

console.log(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/143.0.0.0 Safari/537.36 Edg/143.0.0.0

Challenge Information:

Build a Pyramid Generator - Build a Pyramid Generator

  console.log("Actual:   ", JSON.stringify(pyramid("o", 4, false)));
  console.log("Expected: ", JSON.stringify("\n   o\n  ooo\n ooooo\nooooooo\n"));
  console.log("Actual:   ", JSON.stringify(pyramid("p", 5, true)));
  console.log("Expected: ", JSON.stringify("\nppppppppp\n ppppppp\n  ppppp\n   ppp\n    p\n"));

Add this code to compare actual to expected results.

a quel niveau dois je ajouté ce code? dans la fonction ?

At the bottom of your code. Just like you did for this log:

Actual:    "ooooooo"
Expected:  "\n   o\n  ooo\n ooooo\nooooooo\n"
ppppppppp
 ppppppp 
  ppppp  
   ppp   
    p    
Actual:    "    p    "
Expected:  "\nppppppppp\n ppppppp\n  ppppp\n   ppp\n    p\n"
   o   
  ooo  
 ooooo 
ooooooo
ooooooo
c'est le résultat de la console

What does your pyramid function return? Please review User Story #5.