What's wrong with this code


#1


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


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

what is wrong with this code


#2

Ok, first off, you do not need to console.log number after return number * 2. That will come later on in the code. Secondly, for var newNumber you need it to equal the number in timesTwo times two so in your case 16. And you need that number in quotes so "16"; Now instead of returning again you need to console.log newNumber not number. You also do not have to call newNumber at the end. All in all here is a basic outline: (All // are comments btw not necessary to code)

var timesTwo = function(number) {
    return number * 2; //no console.log yet!
};

timesTwo(8);
var newNumber = "timesTwo number times two"; // so 8 times 2 = what?
console.log(newNumber); //now console.log but no return or call!

#3

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