Functional JavaScript!

fixed the javascript so the game is playable.