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.
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!
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.
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.
You can use a loop to do something over... and over...
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!