Return a Value from a Function with Return
Problem Explanation
Using return
, you can make functions output data.
Solutions
Solution 1 (Click to Show/Hide)
function timesFive(num) {
return num * 5;
}
Using return
, you can make functions output data.
function timesFive(num) {
return num * 5;
}
Solution to this challenge is:
Mod edit: solution removed
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
This was a very simple and easy challenge for me. Here is the solution of
Mod edit: solution removed
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.
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.
my variant:
// Example
function minusSeven(num) {
return num - 7;
}
// Only change code below this line
function timesFive (multiFive) {
multiFive *= 5;
return multiFive;
}
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;
}
var answer = timesFive(2);
** Also gives me a correct result the the (incorrect) answer of 25!! (Pretty sure this is the correct solution, with an answer of 10)
Hello campers,this is how i did it:
Mod edit: solution removed
Attention!:
a bug,since when you put any other number apart from 5,you get 25 instead of the logical output.Someone with an idea how we can debug this challenge?Highly appreciated.
I meant:
var answer = timesFive(3);
should output 15.