Is there any other way to do a return statement other than discussed in the above thread?

Continuing the discussion from freeCodeCamp Challenge Guide: Return a Value from a Function with Return:

function timesFive (bum) { return bum * 5;}

I was specifically wondering if num is a reference word.

I am not sharing this as the forum as I view the problem solving skills required as everyones own journey :-):sunglasses:

Is the short answer: because this is the way the language works?

As you notice, I changed num to bum and still got the challenge correct.

Yes bum is just what you’re calling the input you give to the function. When you invoke the function you are most certainly passing some value into the function. The function uses your declaration to see what you want to do with the input and then uses return as a way to output whatever you did to the data. You can call it whatever you want which is why whether it is a num or a bum it works.

No.

Yes.

You can give it (almost) any name you like. You can then use that name to access what is passed to the function.

So if you call timesFive(3), it will give bum the value of 3.

Can you write what your example would output, the written code? If you don’t mind to illustrate…

Running timesFive(3) is the same as running the inner part of your function with bum = 3. Since the only line of code is: return bum * 5; which is: return 3 * 5; it will return 15.

Here is the full code:

function minusSeven(num) {
  return num - 7;
}

// Only change code below this line

function timesFive (bum) { return bum * 5;}

Where are you getting 3 from?

This is the bottom part (from lesson 164)

function timesFive (bum) { return bum * 5;}
timesFive(3);

Why am I getting 25 instead of 15?

Can you put your code in a jsbin or something for us to look at?

Is that like an online editor?

Yes it’s jsbin.com just type the code you wrote and share the link.

Again, this is from lesson 164


// Example

function minusSeven(num) {
 
 return num - 7;

}

// Only change code below this line

function timesFive (bum) { return bum * 5;}

timesFive(3);

So you’re wondering why num stores whatever value you pass to it?

I think so. Is that because num refers to the math library on javascript?

No it’s because num is a parameter of the function. It’s your way of passing input to the function to do something with it. In this case you’re taking the input and and multiplying it by 5. SInce the input you pass in is 3 (indicated when you invoked the function with the line “timesFive(3);”), you’re really saying 3 * 5 which is 15.

return5

Here is another image:

I tried to share it on a javascript editor and it did not work. the online editor is saying it is coming out to 25 still…

You’ll notice it says timesfive(5), not timesfive(3). This is why it’s 25.

As to why it’s doing that, I have no idea. Probably a side-effect of the tests.

Is it an error with the system?