Developing a game using states, allows you to organize your code, while also adding a more complete and dynamic gaming experience for the player. To see this example in action, click here.
I've updated this post to include a new file 'map.js' which contains an independent Map class. Instructions on using it are included below.
Click here to play a live demo. Granted, it's not very exciting, but it proves the concept
One of the things that I wanted in my little game was a randomly generated environment, however, I couldn't seem to find any good tutorials on how to accomplish this. So I had to expand a bit, and figure some things out on my own...