0

Here I define a variable: var number = Math.round(Math.random() * 10); When I plug it into the Chrome DevTools JavaScript Console, I get a very weird error: undefined. I have never seen this error before, and I don't see how the variable is undefined.

Is there something I'm doing wrong?

(I'm sure this is one of those in-plain-sight issues.)

Homberto
  • 165
  • 1
  • 4
  • 14
  • *"Is there something I'm doing wrong?"* Nope, that's normal output in the console, since the `var` statement doesn't return anything. It's certainly not an error. – Felix Kling May 26 '14 at 20:55

1 Answers1

2

That's right. This expression returns undefined - because var doesn't return anything.

But if you type number and press enter you will get the result.

zerkms
  • 249,484
  • 69
  • 436
  • 539