Return to Kroll Design home page

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:



 
« Return


©2012 Kroll Design    info@KrollDesign.net    781.910.3694
Last modified: 12/31/1969 7:00 PM