Exercise One

In this exercise, you will use an IF STATEMENT to create a function which uses branch logic.

1. Create an HTML page. On that HTML page, make a SCRIPT tag with one function; that function should accept ONE argument. Based on the value of that argument, use an if/else statement to either pop up an alert dialog box which says "Ouch", or pop open a new window which brings up AltaVista (http://www.altavista.com/).

2. Place two links inside the BODY of your page, each of which passes a different argument to the function in your SCRIPT tag; one link should trigger the alert dialog box, while the other should trigger the opening of the new window. Again, you are going to be doing this by testing your local argument variable within the function using the if statement discussed earlier. Test your page in the browser. Make corrections, as needed.

View Possible Solution Page.

Main Menu