FAQ: Functions - Helper Functions


#1

This community-built FAQ covers the “Helper Functions” exercise from the lesson “Functions”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Introduction To JavaScript

FAQs on the exercise Helper Functions

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


#2

Hello, I’m currently learning about “helper functions” in “introduction to javascript” here and I 'm a bit confused.

In the following code, the value of 15 is first passed as an argument for the function of getFahrenheit as “celsius” but what I don’t understand is how it’s then again used as an argument for multiplyByNineFifths. How is there a relationship between that function and 15? I don’t understand how they connect.

The lesson attempts to explain it, but I still don’t get it. Here is the code along with it’s explanation

Code:

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

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

getFahrenheit(15); // Returns 59

Explained:

  • 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) .

#3

the lesson does indeed explain this:

The code block inside of getFahrenheit() calls multiplyByNineFifths() and passes 15 as an argument.

the value 15 is passed as argument to celsius parameter, then the celcius parameter (which now has a value of 15) is passed as argument to the parameter of multiplyByNineFifths function