# freeCodeCamp Challenge Guide: Return a Value from a Function with Return

freeCodeCamp Challenge Guide: Return a Value from a Function with Return
0

#1

We can pass values into a function with `arguments`. You can use a `return` statement to send a value back out of a function.

## Example

``````function plusThree(num) {
return num + 3;
}
var answer = plusThree(5); // 8
``````

`plusThree` takes an `argument` for `num` and returns a value equal to `num + 3`.

A `return` statement will also end the execution of it’s parent function. Hence, any statements inside a function scope after a `return` statement will not be executed. In case of multiple `return` statements in a function, only the first one will get executed.

SOLUTION:

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

var answer = timesFive(5); // 25
var answer = timesFive(2); // 10
var answer = timesFive(0); // 0

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

Solution to this challenge is:

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

// Only change code below this line
function timesFive(num) {
return num * 5;

}

#3

Hi everyone. I think this challenge has a bug:

As you can see I set to the parameter “mult”, the argument of 3, but the result that freeCodeCamp is showing on the down-left side for timesFive function is 25. So it’s assigning a preset value of 5 istead of 3 as I wrote it.

Does anybody else met this issue before?

I’m new here and I don’t know where to post this bug, so I followed their steps and end it up here.
Sorry if I misunderstood something. Thanks

#4

This was a very simple and easy challenge for me. Here is the solution of it.

``````// Example
function minusSeven(num) {
return num - 7;
}

// Only change code below this line

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

#5

Yes, I also did this after I red your post, and unfortunately the result was same. I think it may be a bug. I agree with you.

#6

this is definitely bugged

expected: 50,

shows 25

#7

it does this in most of the solutions that can have multiple inputs. So, my guess is, the webpage itself is not running a compiler where you can test results. I reckon you must use compiler to see actual results.

#8

my variant:

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

// Only change code below this line

function timesFive (multiFive) {
multiFive *= 5;
return multiFive;
}

#9

Some of these posts are 4 months old, and this problem still has the same bug. I tried to solve this two different ways, but no matter what I do, I get the answer of 25, even when the solution is incomplete:

function timesFive(num)
{
return num * 5;
}
** Gives me a correct result with answer of 25 (but no argument being passed into the function!)

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

** Also gives me a correct result the the (incorrect) answer of 25!! (Pretty sure this is the correct solution, with an answer of 10)

#10

Hello campers,this is how i did it:

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

// Only change code below this line

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