JavaScript Tutorials
« Return
if statement
With if statements, make sure to enclose the conditions in parens, and to enclose the actions in curly braces:
Code:
<script type="text/javascript">
//<![CDATA[
a = 1;
b = 1;
if (a == 1) { document.write("fyi: a is equal to 1 <br><br>"); }
if (a == b) { document.write("a and b are equal"); }
else { document.write("a and b are not equal"); }
</script>
Output: