Function challenge

please how did fcc get this final result ```
processArg(7)

  **Your code so far**

// Setup
let processed = 0;

function processArg(num) {
return (num + 3) / 5;
}

// Only change code below this line
processed = processArg(7);
console.log(processArg)
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0

Challenge: Assignment with a Returned Value

Link to the challenge:

I’m not sure what you mean. FCC didn’t “get this final result”. Your browser calculated it using JavaScript and math.

One issue I see, you have:

console.log(processArg)

That will log out the function itself. I assume that you want the result. You can either do:

console.log(processed)

or

console.log(processArg(7))

to see the answer.

If you want to understand how that happens, that number 7 is passed into that function and is accepted as the first parameter, and we tell the function to call it “num” (inside the function). Then we do our math and return the value.

If that didn’t answer your question, please ask a specific question.

1 Like

why was it passed through the function?? and why was it accepted??

HI @columbuschidozie1 !

It looks like there is some confusion on how function calls work.
Let’s walk through the problem.

We have this function here

and the only thing that the function does is return a value based on this mathematical equation.

This part here is the parameter

Parameters are placeholders for the real value when we call the function later on.

This part here is our function call

Function calls use the name of the function and pass in a real value.
We could have used any number here.
But in this case we are using the number 7 in our function call.

What happens now, is that the number 7 will be used in this mathematical equation.

(num + 3) / 5
can be written as 
(7 + 3) / 5

If we do the math out then we have this result

(10)/5 equals 2

This function call processArg(7) will return the number 2.

The last part is that we are assigning the number 2 to this variable here called processed

processed = processArg(7)
this can be rewritten as 
processed = 2

If you console.log(processed) then you should the number 2 in the console.

Hope that clears things up!

1 Like

thank you so much like you just broke down the whole thing to the point that i understood everything

1 Like