I am a newbie. I have been learning javascript and I feel like I almost grasp it but I am a very visual learner and I am having trouble visualizing how this works. I am learning with code academy. My ultimate goal is to understand how inputs and outputs are inserted into reusable functions.
I understand the general idea, but I get lost in the details of how the argument flows through or is ‘passed’ to the functions.
My specific questions are:
- When I call
getFahrenheit(15), where exactly is the ’15’ passed to? - In
getFahrenheit(celsius), the argument is named ‘celsius’. Does ’15’ replace ‘celsius’ inside that function, and then get passed intomultiplyByNineFifths()? - In
multiplyByNineFifths(number), does ’15’ replace ‘number’, so the second line becomesreturn 15 * (9/5);? - When multiplyByNineFifths() returns ’27’, does that mean the call inside
getFahrenheit(celsius)effectively becomes27 + 32? - Finally, does the code re-run both functions again, or is it just passing the returned value along?
The code below is a snippet example that I have questions about. No setup or context needed. This is the exact code I want to make sure I understand how it works.
function multiplyByNineFifths(number) {
return number * (9/5);
};
function getFahrenheit(celsius) {
return multiplyByNineFifths(celsius) + 32;
};
getFahrenheit(15); // Returns 59
I think my confusion is mostly about whether the return value actually “replaces” the function call inside the other function, or whether something else is happening behind the scenes.
I have tried googling my question and have not been able to find the answer. I googled “how do helper functions in javascript work?” I have found several questions about helper functions (like what they do, how they can improve readability of code, etc.), but none that explain how a code like this works. I am just looking for some helping clarifying how the inputs and outputs visually flow through when the getFahrenheit(15) function is called. I also read all ‘similarly phrased questions’ and do not see an on point explanation.




