1/6 Question about when to use "var". (possible bug?)


#1

I do not understand when to use "var" when declaring a variable and when can I skip it.
Default code in this lesson says "slaying = false;" in line 15 and 21 and after clicking "Save & Submit Code" everything seems to work, but console prints "false" on the end for some reason. When you change "slaying = false;" to "var slaying = false;" code work properely. What's the deal here?


#2

Can you show us your code? @szyszak Then we can fix it!


#3

The code is already there in this lesson, here is a screenshot without "var" in line 15 and 21 http://imgur.com/WHXdl7D

And here is with "var" http://imgur.com/GKIoPmQ

So the code works either way, but without "var" is prints "false" in the console for some reason and it doesn't look right.