previousnext

Adding sound is fine ... but sometimes you may want to have the option to turn it off without changing the code. I have used the variable speaker_on (in the source code of this html file) to link the state of the "speaker on/off" button; we can use this variable in our code as follows:

Note that I have also moved the code for move back into the library.

Experiment!

Try it! Also, change the code to set the value of speaker_on to false at the beginning and see what that does.

previousnext