mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-23 12:03:28 -05:00
1.7 KiB
1.7 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 660f4774e3e0df35a68bb5f2 | Step 90 | 1 | step-90 |
--description--
To make your pyramid generate again, push the result of calling padRow with done and count as the arguments to your rows array, similar to what you did in your first loop.
--hints--
Your loop should call the .push() method on your rows.
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*rows\.push\(/);
You should call your padRow function in your .push() method.
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*rows\.push\(\s*padRow\(/);
You should pass done as the first argument to your padRow call.
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*rows\.push\(\s*padRow\(\s*done/);
You should pass count as the second argument to your padRow call.
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*rows\.push\(\s*padRow\(\s*done\s*,\s*count\s*\)/);
--seed--
--seed-contents--
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++;
--fcc-editable-region--
--fcc-editable-region--
if (done === count) {
continueLoop = false;
}
}
let result = ""
for (const row of rows) {
result = result + "\n" + row;
}
console.log(result);