Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript VAR only works outside function? Reply To: VAR only works outside function?

#148973
TheDoc
Member

If you only move the var a outside you’ll see that it works: http://codepen.io/ggilmore/pen/5c5e089e6d371d9eb7b9a9b1425f69e1

Also you’ll notice that I threw in a bunch of console logs there. They are super helpful for debugging these sorts of things. On my two clicks I get this in the Console:

1378274053878
1378274053878
3100
false
1378274055173
1295
3100
true