Code fails to work

Tell us what’s happening:


Your code so far

function timesFive(timesThree){
timesThree * 5;
return  timesThree;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36.

Challenge: Return a Value from a Function with Return

Link to the challenge:

I see how you’re thinking here. But that’s not how variables (in this case) work. You can see what’s happening if you replace the variable with an actual value.

You’ve also named things a bit strangely, and though it doesn’t matter what they’re called, it’s a bit confusing to read. So I’m going to rename the argument to what it is in the example:

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

So if I put a number in:

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

Do you see what’s happening? You’re just returning the number that gets put into the function

The variable num gets assigned the value 3. You multiply num by 5, but you don’t do anything with that: it doesn’t change the value of num, num is still 3.

To make it work, you either need to assign a new value to num (num = num * 5), or you need to return the result of num * 5 (like return num * 5)

1 Like