Question: Create a simple JavaScript game where red colored squares are created at random and the user has to click on them to turn them purple.

Create a simple JavaScript game where red colored squares are created at random and the user has to click on them to turn them purple. Do not use jQuery. A demo can be shown on request. Requirements 1. Red squares are created at 0.5 second intervals 2. The squares are positioned randomly 3. The squares turn purple when clicked 4. When the user leaves 5 divs red (because of being unable to color them fast enough), they lose the game and an alert is shown 5. When the user loses the game, no further divs are created Syntax reference This script is doable using your JavaScript lectures, the only additional info needed is given below To produce a random number between 1 and 500: Math.floor((Math.random() * 500) + 1) Remember that to change the position of an HTML element, first set its position value to absolute, then set its top, left, bottom and/or right values. Use 500 max for top and 100 max for left to get positions within reasonable bounds for a laptop screen

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!