Code skill Fixing the Bugs

This piece of code will fix the three bugs in our code. You will need to use an if statement to create a “Game Over!” alert with the player’s score. To stop the snake passing through itself, you will need to code an isSnake function and a loop so that the game ends if the snake moves into a location which is already part of the snake at that moment. You will need to develop your gameControl if statements so that the snake can’t turn back on itself. Lastly, you need to change the order of the drawGame function so that the fruit is never drawn on top of the snake.

See the Pen GB12 M2 by Walker Books UK (@walkerbooks) on CodePen.