Question about function call

There is something that is confusing me, when i run this code it seems to work. What i don’t understand is why it works as i suspected we need to call the variable processed, is this
because of the return statement?

function processArg(num) {

return (num + 3) / 5;

}

// Only change code below this line

processed = processArg(7);

Do you mean why, when you declare processed = processedArg(7), does it not show the value?

Why do we declare processed?
How does return now about the variable processed?

the value outputted is 2

processedArg(7) returns a value and that value is stored inside processed because you have used the assign operator = to do that

For the tests to run, that’s just what it’s asking you to do (assign that value to the variable processed).


In JavaScript, variable assignment only returns undefined. As a side effect, the value on the right hand side is assigned to the variable name on the left hand side. So processed = processedArg(7) is not going to return the value of processedArg(7). The value of processedArg(7) (which is 2) has been assigned to the variable processed. So to see what it is, you have to look at processed

You have to catch the value that is returned by the function. One way to do is to declare a variable and store that returned value into it.