Stuck "Return keyword"


#1

I’m stuck at “7.Return keyword”.Below is what I wrote.I don’t understand very well this key

``` var timesTwo = function(number) { return number * 2; }; timesTwo(8); // Call timesTwo here! var newNumber = function(timesTwo) { return timesTwo;}; console.log(newNumber);

Replace this line with your code.

<do not remove the three backticks above>

#2

var timesTwo = function(number) {
return number * 2;
};
timesTwo(8);
// Call timesTwo here!
var newNumber = function(timesTwo)
{
return timesTwo;};
console.log(newNumber);


#3

On line 7, they are looking for you to add the function call after the equals sign:

// Call timesTwo here!
var newNumber =

The above code then would be:

// Call timesTwo here!
var newNumber = timesTwo(8);

The way this works is this:

  1. The code calls the function (invokes it).
  2. The argument 8 is passed to it and assigned to the parameter number.
  3. The function multiples the number by 2.
  4. It returns the result is returned back to the line that called the function.
  5. That result of 16 is then assigned to the variable called newNumber.

Then on line 8, that new number is sent out to the console so that you can view the result.

Does that make sense?


#4

yes. Thanks!I understand now.


#5

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