Back to Freecodecamp

Step 66

curriculum/challenges/english/blocks/learn-introductory-javascript-by-building-a-pyramid-generator/660f34626216270c682e2f7b.md

latest1.4 KB
Original Source

--description--

A <dfn>function call</dfn> allows you to actually use a function. You may not have been aware of it, but the methods like .push() that you have been using have been function calls.

A function is called by referencing the function's name, and adding (). Here's how to call a test function:

js
test();

Replace the character.repeat(i + 1) in your .push() call with a function call for your padRow function. Do not add any arguments to it yet.

--hints--

You should not use i + 1 in your push call.

js
assert.notMatch(__helpers.removeJSComments(code), /repeat\(\s*i\s*\+\s*1\s*\)/);

You should not use character.repeat in your .push() call.

js
assert.notMatch(__helpers.removeJSComments(code), /push\(\s*character/);

You should call padRow in your .push() call.

js
assert.match(__helpers.removeJSComments(code), /push\(\s*?padRow\((.+?)?\)\)/);

You should not have arguments in your padRow call.

js
assert.match(__helpers.removeJSComments(code), /push\(\s*?padRow\(\s*?\)/);

--seed--

--seed-contents--

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

function padRow(rowNumber, rowCount) {
  return character.repeat(rowNumber);
}


--fcc-editable-region--
for (let i = 0; i < count; i = i + 1) {
  rows.push(character.repeat(i + 1))
}
--fcc-editable-region--

let result = ""

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

console.log(result);