CPSC415A
Web Programming

Assignment 8

JavaScript Functions

Use JavaScript to create a simple version of the game Lights Out. The game consists of a grid of lights. When you you click a light, the light and its four neighbors toggle. That is, if the light is on, it becomes off; if the light is off, it becomes on.

To create the game using HTML and JavaScript, use divs or tables to create a 3 by 3 grid of squares with either a light or dark background color. The color of each cell should be randomly generated each time the web page is loaded.

To change the color of the cells, use a JavaScript click event listener function that toggles the color of the clicked cell and its 4 neighbors.

Submission

Submit your code on the course Inquire site.