7. Return keyword - console.log problem


#1

Can you help me to solve it? I don't understand what's the problem with codeand also got console.log error...


#2

Hey @datarockstar84672! The reason you got a problem is that you dont need to set a variable to a function to call the function. Just delete line 6 and 8 and put

timesTwo(5);

This should work, if it didnt please reply saying so!


#3

Hey @datarockstar84672,

I don't see a problem... Did you try refreshing first? :smiley:


#4

Tried :wink: Even closed and reopened website and nothing. In the worst case i can always restart my computer :smiley:


#5

I tried the exact same thing as you did... and it works. :confused:

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

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

Does this code not work? Try it out. :confused:


#6

heehee, funny that, we I hear that said a lot, "have you tried turning it off and on again"... good 'ole IT Crowd :smile:

If you have NOT resolved this, @datarockstar84672, would you mind copying and pasting your code as is here so I could just try it myself please?

Also have you at least tried another browser? Though it find it unlikely, it is possible @ragezapper is on to something here.


#7

Yeah might be because of the browser. :smile:


#8

Wait did you try my method?


#9

Apparently changing browser solved the problem :smiley: Computer computer never changes :wink:


#10

Nice. Now I suggest using that browser that you just used in Codecademy. :smiley:

You don't want to deal with something like that again.


#11

It's my 5th course on codecademy and has never gave me this kind of problems before.


#12

fifth?


#13

Same problem here when using Safari. Works fine with Google Chrome, though.


#14

I copied your code and submitted and it passed but the funny thing is it printed "NaN". I was under the impression it would be integers it would print out.


#15

It should print out integers what was your input? The most likely explanation for NaN would be that the input was not an integer as "Not a number" *2 yields NaN.


#16


#17

Sry for the late response no idea why I didn't got a notification on this one. Yes it is what I expected:
here you call the function:

var nuevoNumero = porDos()

as you leave the () empty you pass no value to the function meaning that the parameter numero inside of the function stays undefined and undefined*number equals Not a Number (NaN). Just pass any number instead idk here again 42 could be the answer (but as well any other number) :slightly_smiling:

PS: the reason for passing is that the function is actually correct you used the right variables and all that stuff it's just that you picked a strange input (no input when an input is expected).


#18

Same issue with my code as well.


#20

this didnt help me. :frowning:


#21

I don't understand what "return" does can you explain it to me?