Javascript implementation of snake game in browser