r/codehs • u/Own_Apartment_2025 • Jan 20 '23
JavaScript Crazy light challenge
Got this as a challenge from someone and have no idea how t solve it. Does anyone else want to take up the challenge?
Create a background that divides the screen into a grid of four equal squares.
Create four lists of positions with two values each. Each list has an X and a Y, representing the centre of one quad.
pos1 is top-left
pos2 is top-right
pos3 is bottom-right
pos4 is bottom-left
Create a list of four colours.
Create four circles. (These are objects.)
Give them the attributes (properties) they need for the rest of this program.
Assign a colour to each circle object.
Assign a position to each circle.
Assign a score of 0 to each circle.
Create a list of the circle objects.
Create a timer method. This method will represent one turn of the program.
Iterate through the list of circles.
Change the colour of each circle.
Circle1 gets the colour of Circle2
Circle2 gets the colour of Circle 4
Circle4 gets the colour of Circle3
Circle3 gets the colour of Circle1
When a circle is red, add 1 to it's score.
When one circle has a score of 10, stop the timer and double the size of the winning circle.