If, else if, else statements define a series of successive blocks of code one of which is executed . One that is executed only when a condition is true, and the other when the condition is false.
<!DOCTYPE html> <html> <head> <title>XoaX.net's Javascript</title> </head> <body> <script type="text/javascript" src="IfElseifElseStatements.js"></script> </body> </html>
var dX = 3.8; if (dX > 5) { document.writeln(dX + " > 5<br />"); } else if (dX > 4) { document.writeln("4 < " + dX + " <= 5<br />"); } else if (dX > 3) { document.writeln("3 < " + dX + " <= 4<br />"); } else if (dX > 2) { document.writeln("2 < " + dX + " <= 3<br />"); } else { document.writeln(dX + " <= 2<br />"); }
© 20072024 XoaX.net LLC. All rights reserved.