Using spread operator question help

////////// PROBLEM 3 //////////

/* Here we have an array with 3 numbers, and a function that takes in 3 numbers as arguments. Invoke addNums, and use the spread operator to pass in the numbers from the numbers array; and store the value to a variable named result */

let numbers = [4, 6, 10];

function addNums(num1, num2, num3) {

return num1 + num2 + num3;

}

// code here

addNums(…numbers)

This is what I have so far. I don’t think I’m too far off on this but

Hello~!

It looks like you are close. I see you are passing in the numbers with the spread operator, but you need to store the value to a result variable.

You can do this by declaring the variable and initialising it with the value of your function call. :slight_smile:

Hey! thanks for your response!

addNums(…numbers)

const result = addNums

I did this but for some reason it’s still failing me.

addNums is a function - const result = addNums is assigning the same function definition to the result variable.

Here you have correctly called the function: addNums(...numbers)
That function call returns a value, which should be assigned to the result variable.

Here is an example of assigning the result of a function to a variable (I’ve blurred it in case you don’t want this much of a hint):

function test(string) {
  return string.split("")
}

const endValue = test("Hello") //endValue now is ["H", "e", "l", "l", "o"]