Build a Pyramid Generator - Build a Pyramid Generator

Tell us what’s happening:

i did this when it was a workshop in a previous version of the course a while ago (js is NOT intuitive to me and i have tried and failed learning it many times lol). i went back and tweaked my code from that workshop but despite it returning what the tests expect, it doesn’t seem to satisfy them? thanx if you can help!

Your code so far

function pyramid(str,int,bool){
  const rows = [];


function padRow(rowNumber, int) {
  return " ".repeat(int - rowNumber) + str.repeat(2 * rowNumber - 1) +  " ".repeat(int-rowNumber);
}

for (let i = 1; i <= int; i++) {
  if (bool === true) {
    rows.unshift(padRow(i, int));
  } else {
    rows.push(padRow(i, int));
  }
}

let result = ""

for (const row of rows) {
  result = result + row + "\n";
}

return result;

};

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36

Challenge Information:

Build a Pyramid Generator - Build a Pyramid Generator

I would honestly do this from scratch instead of copying old code.

Those are really bad parameter names.

Anywho, I would start by checking what the instructions say to output with the actual output your function makes. Is everything exact where the instructions ask, down to the last space and newline?