# Need HELP, not sure what I'm missing

#1

Instructions:

In our example we have a function called timesTwo() that takes in a number and returns the number multiplied by two.

On line 7, after the equals sign, call the function timesTwo with any parameter you want
Line 8 prints out newNumber. Notice how the value we return from timesTwo() is automatically assigned into newNumber.

Mycode:

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

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

console.log(newNumber);

};

timeTwo();

Error Message:

Oops, try again. Your code doesn't look quite right. Did you set var newNumber = timesTwo(n), where n is whatever number you want? newNumber does not print out at all.

#2

You don't have to build your own timesTwo function. All you need to do is to call the function store the returned value in newNumber and then print newNumber to see if everything is ok.

#3

to call timesTwo, you simply use timesTwo(parameter)

var timesTwo = function(number){
newNumber = number * 2;
return newNumber
}

would also be a good idea .

so the full code would be

var timesTwo = function(number){
newNumber = number * 2;
return newNumber
}

timesTwo(originalNumber);

Oh, and if you want it to console.log, just replace return with console.log(newNumber)

Hope that helps

#4

Afaik the exercise really just requires to call the function. Really no need to rebuild the function as it is already here and also no need to change anything on this function. If you want to try things and experiment with what youâ€™ve learned this is great but rather do it e.g. here labs repl.it. In the exercises you might just get confusing output messages as what you try to do might not be what the author of the test function expected to see.

#5

I attempted to not rebuild and just add the function of timesTwo. And this is what I have.
My code:

var timesTwo = function(number) {
return number * 2;
};

// Call timesTwo here!

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

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

I'm not sure what's wrong. Do I need to add anything else?

#6

Thanks for the help but the won't pass.

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 = function timesTwo(number) {
newNumber = number * 2;
return newNumber

}

timesTwo(originalNumber);

Error: Oops, try again. Your code doesn't look quite right. Did you set var newNumber = timesTwo(n), where n is whatever number you want?

#7

this:

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

is what I meant be trying to rebuild the function. The exercise is just asking you to do this:

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

although this is short and easy I highly recommend that you do this with different values of x until you think you understand who calling a function and return works and how this could be useful in coding.