# Exercise 7 : Helper Functions

#1

Can someone help me better understand the lesson portion here?

``````function multiplyByNineFifths(number) {
return number * (9/5);
};

function getFahrenheit(celsius) {
return multiplyByNineFifths(celsius) + 32;
};

getFahrenheit(15); // Returns 59

``````

The lesson states this:

• `getFahrenheit()` is called and `15` is passed as an argument.
• The code block inside of `getFahrenheit()` calls `multiplyByNineFifths()` and passes `15` as an argument.
• `multiplyByNineFifths()` takes the argument of `15` for the `number` parameter.
• The code block inside of `multiplyByNineFifths()` function multiplies `15` by `(9/5)` , which evaluates to `27` .
• `27` is returned back to the function call in `getFahrenheit()` .
• `getFahrenheit()` continues to execute. It adds `32` to `27` , which evaluates to `59` .
• Finally, `59` is returned back to the function call `getFahrenheit(15)`

getFahrenheit is called & passes 15. Got it.

Now why is the block inside getFahrenheit passing 15 to multiplebyninefiths? I get they both have the same argument of ‘celsius’ but they have different function names, shouldn’t that matter here?

And the 2nd part, even after it passes the argument, once it runs back to the 2nd function, why are we putting an argument in there to begin with? If it has a number from the first function, wouldn’t it just be multiplebyninefiths + 32? Ugh, i don’t get it…

#2

you call both, you seem to be suggesting that you are only calling one

The second function doesn’t have it from the first function unless the first function gives it to the second. What are arguments for again? That. If you think something shouldn’t be there, remove it.

#3

I’m having some difficulty understanding this as well, but here’s how I’m seeing this in my own words… Tell me if I’m on the mark at all…

Part of the function of getFahrenheit is that it calls the multiplyByNineFifths helper function (passing, in this case, the 15 up as the argument that gets multiplied by 9/5’s)
and then brings the new number back down to be added by 32?

#4

Functions take input and produce output
…that’s all there is to this

give 1 and 1 to + and you get 2 back

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.