In this task, we are going to give a final touch to the game by adding a countdown timer. With the timer, the players are not only challenged to select the correct sequence but also restricted in terms of time in order to make the game more exciting for the player.
We will need a new file for the timer. Let's create a new empty file and name it
timer.js. With the new file, we also need to import it in the
index.html file, which is done using the following code:
The timer would be a horizontal bar at the top of the game. Its width decreases when you count down the time.
Let's count down the game with the following steps: