var a = 5, b = 4, c = 1 ; if ( a < b + 1 ) { alert("tea, earl grey, hot!"); } else if ( a > b + c ) { alert("Ahead warp factor 9. Engage!"); } else if ( a % b >= c ) { alert("Warp core breach in 20 seconds!"); } else { alert("I sense a lot of anxiety in this room."); }
var i; for (i = 1 ; i <= 15 ; i = i + 1) { if ( i % 3 == 0) { alert(i + " "); } }
for (i = 1; i <= 10; i = i + 4) { if (i % 5 == 0) { alert(i + " is a multiple of 5."); } else { alert(i + " is not a multiple of 5."); } }
<script type="text/javascript"> <!-- /* This is my JavaScript comment * that spans more than 1 line. * document.write("<h1>Hello!<h1>"); </script> //-->
var i, j; for (i = 0; i <= 3; i = i + 1) { for (j = 0; j <= 4; j = j + 1) { if ( (i + 1 == j) ) { document.write("+"); } else { document.write("o"); } } document.write("<br />"); }
3d XyYzZx ABC123 __yes star*it m me_to-2 main money$
var a = 2, b; b = a; document.write("b = " + b + "<br />"); b = b + 1; document.write("b = " + b + "<br />"); b = a / b; document.write("b = " + b + "<br />"); document.write("a = " + a + "<br />");
Evaluate each expression below as TRUE or FALSE.
_______ (1) c / b == 2 _______ (2) c % b <= a % b _______ (3) b + c / a != c - a
document.write("We sell "); document.write("C shells<br />"); document.write("by the<br />sea shore<br />");
<ul> <li>apples</li> <li>oranges</li> <li>pears</li> </ul>
var i = 1, number = 0; do { number = number + i; i = i + 1; } while(i < 5); document.write("number is: " + number);
var x = 1; if (x > 3) { if (x > 4) { document.write("A"); } else { document.write("B"); } } else if (x < 2) { if (x != 0) { document.write("c"); } } document.write("d");
var j, k; for (j = 1; j <= 4; j = j + 1) { for (k = 1; k <= j; k = k + 1) { document.write("*"); } document.write("<br />"); }
var g, h; for (g = 1; g <= 3; g = g + 1) { for (h = 0; h < 3; h = h + 1) { if (g == h) { document.write("o"); } else { document.write("x"); } } document.write("<br />"); }