# Having trouble understanding helper functions

I enjoyed learning and progressing in the functions lesson, but now i have come to this:

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

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

getFahrenheit(15); // Returns 59

I basically do not get anything from this point, could anybody tell me what each does, bc it is impossible for me to understand this part.

Hey and welcome to the forums!

What Iâ€™d suggest doing is mentally (or even writing down on a bit of paper) working out everything you think the function is doing, starting from the getFarenheit(15) function call. It may be a lot to take in at the moment, but hopefully breaking it down step by step will make things a little clearer.

Letâ€™s say as an example we wanted some code that would take some text and do two things, make the text capitalized, and reverse itâ€™s order. We could write that like this:

function reverseText(text) {
return text.reverse()
}

function capitaliseAndReverse(input) {
return reverseText(input).toUpperCase()
}

capitaliseAndReverse("Apple") //Returns ELPPA

So what is this code doing step by step then?

1. Once you call the function capitaliseAndReverse with the input â€śAppleâ€ť, the function reverseText is also called by it, with â€śAppleâ€ť as its parameter.
2. reverseText calls the reverse function on the string to flip it, then returns that value.
3. We now go back to the original function, where toUpperCase() is called on the value that was just returned, yielding the final result, which we then return.

See if you can apply that same step-by-step logic to your code.

Hopefully that helps!

1 Like