Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Actually, the x is defined at the top of the function. The word "var" just so happens to be inside the loop. Javascript defines ALL variables at the top of a function.
You are defining x within the loop and then trying to reference it outside of the loop. Also I am not sure why you are calling parseInt or returning -1 when x is falsy (what if x is zero? isnt that a correct value?).