Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Tell us what’s happening:

It keeps telling me to declare a sum variable and I thought I did that but it does not work so I come here in search of some help !
Am I close or really far from the answer ? And if not what should I do ?

Your code so far


// User Editable Region

function addTwoNumbers(first, second) {
  return first + second
  addTwoNumbers (5,10)
  let sum = addTwoNumbers(first + second)
  console.log(sum)
}

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 OPR/115.0.0.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Hi there. Your are kind of close.

Right now it does indeed return the sum of two numbers , the lines below the return statement never get ran.

In the example provided in the instructions, the sayName function was called below the function. As a result if one were to assign a variable called myName to it, the value of myName would be John Doe.

So I should put it below the function as in the example ?

Hi there! Your function should only have a one line returning statement, that returns the sum of the two parameters.
After the function definition, you need to declare a variable sum and assign it the function with two numbers as a argument. Then log the variable sum to the console.
Currently you have declared the variable assignment and logged the variable within the function code block. also the arguments aren’t correct. You used the parameters of the function, you need to add two numbers as a argument instead.

It works !
I understand better now thanks a lot !

1 Like

function addTwoNumbers (a, b) {
return a + b;
}

let sum = addTwoNumbers(5, 10);
console.log(sum);