Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Tell us what’s happening:

Hi, my console is telling me that my function should return the sum of the two numbers. I should assign “sum” the value from calling the addTwoNumbers function with 5 and 10 for the arguments.
→ I’m not sure what this means, does it want me to add 5+10 somewhere? if so, where?

Your code so far

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

function padRow(name) {
  return name;
}

// User Editable Region

function addTwoNumbers(sum){
return sum;  
}
addTwoNumbers(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/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Hi @firefly.unicorn,

You want your addTwoNumbers function to accept two arguments.

function functionName (arg1, arg2) {
  return arg1 * arg2;
}

Once your function is created, you can assign a variable anywhere outside of it to be the value returned by passing two arguements.

const variable = functionName(4.56, 7.8);

Using the variable we just created, you can console log to see your result.

console.log(variable);

I hope this helps. Happy coding!

1 Like

There are two sets of instructions.

The first one asks you to write a function that adds two numbers (not a specific two but your function should work for any two numbers we give it)

The second part is asking you to call the function and assign its return value to a variable.

Try to complete the first step correctly first.

Are the two arguments here not the same as the numbers passed to functionName?
I coded

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

which returned " You should have a function called addTwoNumbers. Your function should return the sum of the two numbers. You should declare a sum variable" in the console.

Can you please include details on how I can add two numbers without declaring two specific ones? The only solution I know is if I declare two new variables, but I’m not sure that’s what it wants from me here.

This is not the correct way to create two parameters for your function.

You need to actually write two names instead of two numbers. For eg you can use x and y as names.

Thank you so much! It just passed after I renamed my code sum1 and sum2

1 Like

Perfect good work! :trophy:

1 Like

I have looked at many posts about this issue, and this is the only comment that helped. Thanks for the examples!!

1 Like