Sure, here's a simple implementation of the classic Snake Game using JavaScript. You can copy and save the code as a single HTML file and open it in a browser to play the game.
This code sets up a canvas element where the game is rendered. The snake is controlled using arrow keys, and the objective is to eat the randomly placed food while avoiding colliding with the walls or the snake's own body. The game loop updates the snake's movement, checks for collisions, and updates the canvas accordingly. Once the game is over, an alert is displayed, and the game loop is stopped.