Oops, try again. It looks like you didn't print out the value of newNumber


#1

can you help me? find something wrong with my code.

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

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


#2

That's because you have to type a number as a parameter, not a string.


#3

but how do I do THAT?


#4

Were you able to figure this out? I'm having the same problem and getting the same error message. Here is my code:

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

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


#5

@wnemitz, when calling your function, you should not be putting the number in quotes, so it should be var newNumber = timesTwo(2);.
@beantown4545, the entire statement of the number you are doubling should be in the brackets of the function, so var newNumber = timesTwo(6+5);. There should also be no space between timesTwo and (6+5).


#6

The space should not interfere.

 > function timesTwo(x) { 
..   return x * 2; 
..   }
 > timesTwo (6+5)
=> 22

#7

Thanks for the explanation! Much appreciated.


#8

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