Snake game in 5 minutes

About

Snake is a classic arcade game initialy developed in mid 1970-s. Idea is to maneuver a line (aka snake) over rectangular field. The snake grows when its' head comes across an item (aka apple).

Link to Wikipedia: https://en.wikipedia.org/wiki/Snake_(video_game_genre)

Live coding

Here is a live coding session that shows how it can be done.

Duration: 4:54

Sources: https://github.com/5minute/examples/tree/main/snake

See live results:https://jsfiddle.net/9syua76k/

Disclaimer: never use this code in production. It was created for fun.