If-Then-Else Statements


Another thing that JavaScript cannot do without would be if-then-else statements. These allow you to set conditions, lets see an example:
<Script language="JavaScript">
if(1=1){
alert("Hi");
}else{
alert("Bye");
}
</Script>

When this function is used, it will check if 1 equals 1, if it does it will display "Hi" if it doesnt it will display "Bye". Of course 1 will always equal 1. For this to be useful you must use variables. In the next lesson we will learn how to use a radio button to get user input. 1