Codecademy Forums

FAQ: Functions - Helper Functions

Hey guys I am currently reading the "Helper functions in the introduction to javascript course and just confused.

The part that is confusing me is the return command. Below is the current code that I’m looking at

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

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

getFahrenheit(15); // Returns 59

In the function multiplyByNineFifths(number), where is the return number * (9/5); that value to?

to the caller, which is here:

multiplyByNineFifths(celsius) 

Still don’t get it >.> ugh. How is multiplyByNineFifths(celsius) getting celsius as a param in the first place?

here:

getFahrenheit(celsius)

you define (name) a function with a parameter named celsius.

then here:

multiplyByNineFifths(celsius)

you call the multiplyByNineFifths function with argument (celsius), which is the parameter of getFahrenheit function

so a function can call a different function with its parameter as argument for the different function.

Alright that makes sense now. But the returned property. Does it return the value to the function that has the parameter?

a function call will execute a function

at the end of a function, return can hand back data to the caller (the function call)

Thank you so much. This has helped me a lot