JavaScript if ... else if ... else

Use the else if statement to specify a new condition if the first is false.

This example will write a link to either W3Schools or to the World Wildlife Foundation (WWF). By using a random number, there is a 50% chance for each of the links.