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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started