Discuss Scratch

StarscreamClone
Scratcher
1000+ posts

Reference error: 'console' is not defined

Alright, so when I type this into my JS compiler in my iPad application or on the compiler in Khan Academy, this error pops up. Is there a reason it's doing this when it will work fine in the Codecademy one?

Thank you,
Isaac
djdolphin
Scratcher
1000+ posts

Reference error: 'console' is not defined

StarscreamClone wrote:

Alright, so when I type this into my JS compiler in my iPad application or on the compiler in Khan Academy, this error pops up. Is there a reason it's doing this when it will work fine in the Codecademy one?

Thank you,
Isaac
What exactly do you mean by ‘this’?
scimonster
Scratcher
1000+ posts

Reference error: 'console' is not defined

The iPad probably doesn't support the console.
You should probably define it at the top of your code as a fallback:
var console = console || {log: function(){}};
This won't break console.log() statements.
StarscreamClone
Scratcher
1000+ posts

Reference error: 'console' is not defined

scimonster wrote:

The iPad probably doesn't support the console.
You should probably define it at the top of your code as a fallback:
var console = console || {log: function(){}};
This won't break console.log() statements.
I would have thought that, too, but it was built into the application, believe it or not. There are tons of 'em.
Anyway, thank you so much. I appreciate it.

Powered by DjangoBB