Learn Introductory JavaScript by Building a Pyramid Generator - Step 89

Tell us what’s happening:

need help i dont get how do i make the arguments for done and count

Your code so far

const character = "#";
const count = 8;
const rows = [];

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

// TODO: use a different type of loop
/*for (let i = 1; i <= count; i++) {
  rows.push(padRow(i, count));
}*/

let continueLoop = false;
let done = 0;

while (continueLoop) {
  done++;

// User Editable Region

while (rows.push(padRow)) {
  done++;
  count++;
}

// User Editable Region

  if (done === count) {
    continueLoop = false;
  } 
}

let result = ""

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

console.log(result);

Your browser information:

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

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 89

padRow is a function, and it takes two arguments. The challenge requires you to pass done and count as arguments, and push the result of it into the array rows.
There is no request to create a new while loop.
For clarification this is how I call the function sum with the arguments 3 and 5:

sum(3,5)
1 Like

Hello!

luisclaudioc has provided good guidance.

Just a suggestion:

I would reset the step (it will not affect any previously completed steps but will clear this one for a fresh beginning).

View your Comment (in the previous code above where this code is to be entered) to see how you have mentioned the row.push function, and see how to do it. Instead of the i and count arguments, you would use the done and count arguments.

Hint: I usually try to look back to see if I can use any of my previous code for guidance on a current step or lesson.

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