You may want to do different things depending on the value of a variable. An if statement is always structured like this:

if (test conditions go here) {

The test inside the brackets will be explained next. The principle is that if the test passes any code inside the braces (curly brackets) will be run. If the test fails nothing happens.

Open inline.html and save it as jsif.html.  If you did not do the HTML and CSS tutorials you will need to create this page which has an inline style setting the background colour of the page to yellow.  It also has at least two paragraphs.

You already know how to find the current in-line style of an HTML element using JavaScript and how to change that style. Here put that together with an if statement to change the style unless it has already changed.  Paste this code just under the title in jsif.html:

<script type="text/javascript">
    function changeColour () {
        if ('yellow') {

Add an onmouseup event trigger to the second paragraph.  The event trigger goes in the opening tag and calls the function above by name.

If your in-line style in the body tag does not set the background colour to yellow change it to yellow now.

Save the file and click on the second paragraph in your browser and the background should change.  Click again and nothing happens as it is no longer yellow.  More on what to do then on the next page.