Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Tell us what’s happening:

I keep getting this error that my function should return the sum of the two numbers, which it does give me the output of 15. What am I doing wrong. I am having trouble grasping the concepts.
// running tests
Your function should return the sum of the two numbers.
// tests completed
// console output
15
CamperChan

#######
########

Your code so far

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

function padRow(name) {
  return name;
}

// User Editable Region

function addTwoNumbers() {
  return 5 + 10;
} 
const sum = addTwoNumbers (5 + 10);
console.log(sum);

// User 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 + "\n" + row;
}

console.log(result);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

You created a function as they wanted but you haven’t done everything they asked for.

The next thing you needed to do was:

This function should take two arguments

After that, you need to add the parameters and return them.

Please note this is not how you call a function that takes two arguments.
You should provide a comma separated list of arguments 5,10 not 5+10

1 Like

So the first part of the code should look like this correct?

function addTwoNumbers (5, 10) {
return 5 + 10;
}

instructions for this part:Declare a function named addTwoNumbers . This function should take two arguments and return the sum of those two arguments.
arguments for the function should be alphabetical.

1 Like

So you mean something like this when you say alphabetical: (num1, num2).

If so, please explain. I am having some difficulty grasping the concepts. They kind of come in and fade. I hope that means I am in the right direction.

1 Like

You cannot hard-code function parameters like this. You need to review how to create functions:

https://www.w3schools.com/js/js_function_parameters.asp

https://www.freecodecamp.org/news/javascript-function-iife-parameters-code-blocks-explained/

If you’re ever unclear on something you need to search for it and review it. You should be doing this all the time and get used to it.

1 Like