Problem with 7. Return keyword


#1

I keep getting the message "Oops, try again. It looks like you didn't print out the value of newNumber"

But I can see the number appearing in the console. Any idea what I'm doing wrong? The code is below. Thanks

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

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


#2

Never mind. I realised it was because of the quote marks around the number. A delete function would be useful...


#3

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

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

Can anyone tell me what wrong with above code ???
even though it displays the output , "Oops, try again. It looks like you didn't print out the value of newNumber"


#4
console.log=(newNumber);

in the end console.log is nothing but a variable and what happens with variables in situations like that? They get a value assigned. So not only does it not print your value it also turns your console.log function into a useless number :frowning:
So fix this by deleting the = and also refresh the page to reset the built-in values.


#6

dont wrap 10 wid ("")..


#7

It didn't work for me :frowning:


#8

I have the same problem too. I am confused. :frowning:


#9

I want back and solved problem like this: :smile:

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

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


#10

I keep getting the same message, that I didn't print out the value of newNumber. Can anyone help?

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

// Call timesTwo here!
var newNumber = (98)
console.log(newNumber);
timesTwo(98)
var val = 98 * 2;


#11

Well this exercise is not that hard so this should not be a huge spoiler:

Use the timesTwo function to assign a value to newNumber

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

Still I'd recommend that you try some more value to get familiar with the features of return as this is a mighty tool that can be very helpful!