Trying to learn javascript by coding a little game