mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-22 19:43:28 -05:00
2.0 KiB
2.0 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 660f535ec33a285b33af3774 | Step 116 | 1 | step-116 |
--description--
When inverted is false, you want to build a standard pyramid. Use .push() like you have in previous steps to achieve this.
--hints--
You should call the .push() method of rows in your else block.
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*rows\.push\(\s*/);
You should pass a padRow() call as the argument for your .unshift() method.
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*rows\.push\(\s*padRow\(/);
You should pass i as the first argument to your padRow() call.
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*rows\.push\(\s*padRow\(\s*i/);
You should pass count as the second argument to your padRow() call.
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*rows\.push\(\s*padRow\(\s*i\s*,\s*count\s*\)/);
--seed--
--seed-contents--
const character = "#";
const count = 8;
const rows = [];
let inverted = true;
function padRow(rowNumber, rowCount) {
return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber);
}
// TODO: use a different type of loop
--fcc-editable-region--
for (let i = 1; i <= count; i++) {
if (inverted) {
rows.unshift(padRow(i, count));
} else {
}
}
--fcc-editable-region--
/*while (rows.length < count) {
rows.push(padRow(rows.length + 1, count));
}*/
/*for (let i = count; i > 0; i--) {
rows.push(padRow(i, count));
}*/
let result = ""
for (const row of rows) {
result = result + "\n" + row;
}
console.log(result);