<!-- Example of an IF statement with && operator (AND), which joins to logical operators. -->
<script language="javascript" type="text/javascript">
var year = 2005;
var team = "White Sox";
if (year == 2005 && team == "White Sox" )
{
document.write("This team won the World Series.<br/>");
}
else
{
document.write("This team did not win the World Series.<br/>");
}
</script>
<!-- Example of an IF statement with || operator (OR), which joins to logical operators. -->
<script language="javascript" type="text/javascript">
var year = 2010;
var team = "White Sox";
if (year == 2005 || team == "White Sox" )
{
document.write("This team is great.<br/>");
}
else
{
document.write("This team is not great.<br/>");
}
</script>
<!--DETAIL!!! -->
<!-- Example of an IF statement with && operator (AND), which joins to logical operators. -->
<script language="javascript" type="text/javascript">
var year = 2005; // Creates variable year and assigns a value of 2005
var team = "White Sox"; // Creates variable team and assigns value 'White Sox'
if (year == 2005 && team == "White Sox" ) // If year equals 2005 AND team equals "White Sox" (== is the symbol for equivalency),
{
document.write("This team won the World Series.<br/>"); // write this.
}
else // If the logical test in the IF statment isn't true, then,
{
document.write("This team did not win the World Series.<br/>"); // write this.
}
</script>
<!-- Example of an IF statement with || operator (OR), which joins to logical operators. -->
<script language="javascript" type="text/javascript">
var year = 2010; // Creates variable year and assigns a value of 2010
var team = "White Sox"; // Creates variable team and assigns value 'White Sox'
if (year == 2005 || team == "White Sox" ) // If year equals 2005 OR team equals "White Sox" (== is the symbol for equivalency),
{
document.write("This team is great.<br/>"); // write this.
}
else // If the logical test in the IF statment isn't true, then,
{
document.write("This team is not great.<br/>"); // write this.
}
</script>