7. Return Keyword


#1

help!!!
// Parameter is a number, and we do math with that parameter
var timesTwo = function(number) {
return number * 2;
};

timesTwo(42)
var newNumber = function(timesTwo){
console.log(newNumber)};


#2

Actually the exercise is much more simple:

var newNumber = timesTwo(42)
console.log(newNumber);

The idea is that you play around with this and get an understanding how return can be used to retrieve a value from a function. You don't need to rebuilt the function here. So as this is an important concept better test it a bit enter different values and see what is happening.


#3

I did this and it worked

// Parameter is a number, and we do math with that parameter
var timesTwo = function(number) {
return number * 2;
};

// Call timesTwo here!
var newNumber = timesTwo(5);
console.log(newNumber);


#4

Thank you for your help :smile:


#5

It flags up a whole lot of errors when my syntax is correct. Don't bother folks. There has to be better courses out there.