Snake is a fun game to make as it doesn't require a lot of code (less than 100 lines with all comments removed). This is a basic implementation of the snake game, but it's missing a few things intentionally and they're left as further exploration for the reader.
Further Exploration Score When the snake eats an apple, the score should increase by one. Use context.fillText() to display the score to the screen Mobile and touchscreen support Allow the game to be scalled down to a phone size. See https://codepen.io/straker/pen/VazMaL Support touch controls Better apple spawning Currently the apple spawns in any random grid in the game, even if the snake is already on that spot. Improve it so it only spanws in empty grid locations