Obviously you are not expected to master JavaScript programming in the last few weeks of this module. Thus you are given a template HTML file with an almost complete JavaScript program already coded in it. You will need to read a bit about JavaScript so you understand the basic elements of its syntax. But the basic principles of algorithms are coded in JavaScrip are in many ways quite close to Python. So your knowledge of Python should enable to carry out the limited coding tasks required for this assignment.
For this coursework you will create a Javascript program that
implements the simple puzzle known as Lights Off.
You should start with the template file lights_off.html (which you
can download using the link below). That file contains HTML and Javascript code that,
when opened in a browser,
will display a grid of buttons and implements a function toggle(i,j)
that switches the state of the button at position (i,j) in the grid between
the yellow O state (on) and the black X state (off).
lights_off.html file to display a heading and brief information about the game
and ensure that this text and the grid are centred on the page. Thus, the web page seen when the
lights_off.html is viewed in a browser should look similar to this:
press function so that, as well as toggling the state of the button actually
pressed, the state of buttons above, below, left and right of the button pressed are also
toggled. Thus, if one presses the centre button followed by the middle button of the top
row, one should see the following changes:
| Pressing the centre button gives: | Then pressing the middle button of the top row gives: |
![]() |
![]() |