Introduction to Functions in JS 7/13


#1

I could not write correct code;

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

// Call timesTwo here!
var newNumber = function(timesTwo){
console.log(timesTwo);
};
newNumber(timesTwo);

Where did I go wrong??


#2

Hi,

I think you got a bit confused on the 2nd part, you have already defined the function, line 7 is asking for you to use the function with any number you like. So it should look like this -

// 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);

Thanks

Keith


#3

ohhh tnx. I did it. i forget

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

:smile: