curriculum/challenges/english/blocks/learn-introductory-javascript-by-building-a-pyramid-generator/66643c93e05093c728abdbe9.md
Before moving on, take a moment to review how functions work.
Declare a function named addTwoNumbers. This function should take two arguments and return the sum of those two arguments.
Your function should not use hard-coded values. An example of a hard-coded function might be:
function sayName(firstName, lastName) {
return "John Doe";
}
sayName("Camper", "Cat");
This function would return "John Doe" regardless of the arguments passed to the parameters firstName, and lastName, so "John Doe" is considered a hard-coded value.
Declare a sum variable and assign it the value of calling your addTwoNumbers function with 5 and 10 as the arguments. Log the sum variable to the console.
You should have a function called addTwoNumbers.
assert.isFunction(addTwoNumbers);
Your function addTwoNumbers should have two parameters.
assert.lengthOf(addTwoNumbers, 2);
Your function should return the sum of the two parameters.
assert.strictEqual(addTwoNumbers(5,10), 15);
Your function should not return a hard-coded value. That is, it should work with any two number arguments.
assert.strictEqual(addTwoNumbers(3, 5), 8);
You should declare a sum variable.
assert.isDefined(sum);
Your sum variable should have the value 15.
assert.strictEqual(sum, 15);
You should assign sum the value from calling the addTwoNumbers function with 5 and 10 for the arguments.
assert.match(code, /sum\s*=\s*addTwoNumbers\s*\(/);
You should log your sum variable.
assert.match(code, /console\.log\(\s*sum\s*\)/);
const character = "#";
const count = 8;
const rows = [];
function padRow(name) {
return name;
}
--fcc-editable-region--
--fcc-editable-region--
const call = padRow("CamperChan");
console.log(call);
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);