How do we use the return function?

What button do I press to activate the return function? The guy didn’t make it explicit on what to press

function toCelsius(f){
   var result = (f-32) * (5/9);
   return result

Which guy? Is this an online tutorial that you are following?

The same bro dude

For the benefit of anybody reading this thread who has not read your other thread, it would be helpful to post the link, @Growly.

I believe this is it:

1 Like

The url that helps also gives the timestamp, which is

There is no button to press. As you can see from the video, the return happens when the function is called, and the result is shown on the console.

You would want a separate line similar to myTemp, that uses the toCelsius() function instead.

1 Like

Is return a variable that adapts to any variable that has the function name?

and sheesh, I really misinterpreted what he was saying to me.

The return keyword has a special purpose when it comes to functions.

When a function is called, such as with toFarenheit(23.5), that function is invoked (run, executed, called, there are many similar terms) and whatever is returned from the function is used.

With the following:

var myTemp = toFarenheit(23.5);

the function returns a value of 99.9, so the myTemp variable is assigned that value of 99.9

If the function didn’t return anything, it would be undefined that is assigned instead.

function toFarenheit(c){
   return (c * 9/5) + 32;


var myTemp = toFarenheit(37.7);

“myTemp” is returning the value 37.7 to (c *9/5) + 32; and solves it?

if correct, “return” only works for specific values like toFarenheit or toCelcius?

Sorry but no.

myTemp is like a bucket, and it has whatever is given to it by the equals-sign assignment. In the situation of this example, that is whatever is returned from the function.

When the line is:

var myTemp = toFarenheit(37.7);

what ends up being stored in the myTemp variable is whatever is returned from the toFarenheit function.

It can almost be read backwards, where 37.7 is given to the toFarenheit function, and whatever is returned from that function is assigned (using the = sign) to the myTemp variable.

“what ends up being stored in the myTemp variable is whatever is returned from the toFarenheit function.”

So the value “toFarenheit(37.7)” established the return function to myTemp and MyTemp is now apart of the function as long as the value is there, and now it can return it to the function and solve it?

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