Javascript Test Page

My first piece of Javascript!

Alert Dialogue

You will have already seen a basic alert dialogue when this page finished loading.
Now for an alert triggered by a user action. In this case a simple onclick action on a button.

Using Variables

The unit code is ! Wow, I can put Javascript code wherever I want! And I can declare variables in block of javascript in one place, and then use them in another place later in my page!

Creating a function

Functions let you define some functionlity that you can use later. Once you have declared a function, you can use its name to call it later.

Using Logic

Conditional Statements

You could use something like this to check if some condition is met before displaying content. Or use it to decide what of two different things to display.

Looping

You can use a loop to do something over... and over...

Combining it all

Lets put it all together into one function!

I want to display a list of my friends, but if the list contains the name of my best friend, Edith, I want it to be highlighted!