curriculum/challenges/english/blocks/learn-introductory-javascript-by-building-a-pyramid-generator/660f2b6fd54ac1fc142804dd.md
The logic for formatting this pyramid is likely going to get complicated, which means it's a great time to extract that code into a function.
A <dfn>function</dfn> is a block of code that can be reused throughout your application. Functions are declared with the following syntax:
function name(parameter) {
}
The function keyword tells JavaScript that the name variable is going to be a function. parameter is a variable that represents a value that is passed into the function when it is used. A function may have as many, or as few, <dfn>parameters</dfn> as you'd like. Like a for loop, the space between the curly braces is the <dfn>function body</dfn>.
Declare a padRow function. Do not create any parameter variables yet. The function body should be empty. Remember that you need to use camel case for your naming convention.
You should use the function keyword.
assert.match(__helpers.removeJSComments(code), /function/);
You should declare a padRow function.
assert.isFunction(padRow);
Your padRow() function should not have any parameters.
assert.match(__helpers.removeJSComments(code), /padRow\s*\(\s*\)/);
Your padRow() function should have an empty body.
assert.match(__helpers.removeJSComments(code), /padRow\s*\(\s*\)\s*\{\s*\}/);
const character = "#";
const count = 8;
const rows = [];
--fcc-editable-region--
--fcc-editable-region--
for (let i = 0; i < count; i = i + 1) {
rows.push(character.repeat(i + 1))
}
let result = ""
for (const row of rows) {
result = result + row + "\n";
}
console.log(result);