Core JavaScript

If Statements

If statements define a block of code that is executed only when a condition is true.

IfStatements.html

<!DOCTYPE html>
<html>
<head>
    <title>XoaX.net's Javascript</title>
</head>
<body>
    <script type="text/javascript" src="IfStatements.js"></script>
</body>
</html>

IfStatements.js

var dX = 10.23;

if (dX > 9) {
	document.writeln(dX + " > 9<br />");
}

if (dX < 5) {
	document.writeln(dX + " < 5<br />");
}
 

Output

 
 

© 2007–2024 XoaX.net LLC. All rights reserved.