15 Puzzle Game - JavaScript

15 puzzle program consists on 4 by 4 board for a total of 16 slots. One of the slots is empty. The other slots are randomly numbered from 1 to 15. The user's goal is to arrange the tiles to order them in incremental manner. The program allows the user to swap the positions of the open position and an adjacent tile. A count up timer is displayed when the game is started. I have used Document Object Model (DOM) and click event to create this program.

When the game is finished the user is asked to play again or not. If he/she chooses to play again, numbers are scrambled using Math.random. Also each time the page is refreshed, numbers are selected randomly and the timer is displayed as well.

The source code can be found here

Popular Posts