console
var a = 1;
var b = 2;
var condition1 = a > b;
if (condition1) {
document.writeln("line 6: a > b: " + condition1 + "<br/>");
}
if (condition1) {
document.writeln("line 10: a > b: " + condition1 + "<br/>");
}
else {
document.writeln("line 13: a > b: " + condition1 + "<br/>");
}
var condition2 = a < b;
if (condition1) {
document.writeln("line 18: a > b: " + condition1 + "<br/>");
}
else if (condition2) {
document.writeln("line 21: a < b: " + condition2 + "<br/>");
}
else {
document.writeln("line 24: a is not more than b and not less than b" + "<br/>");
}
a = b;
condition1 = a > b;
condition2 = a < b;
if (condition1) {
if (condition2) {
document.writeln("line 33: Wow, there is something wrong." + "<br/>");
}
else {
document.writeln("line 36: a > b: " + condition1 + "<br/>");
}
}
else {
if (condition2) {
document.writeln("line 37: a < b: " + condition2 + "<br/>");
}
else {
document.writeln("line 44: a is not more than b and not less than b" + "<br/>");
}
}
switch (1) {
case 1:
{
document.write(1 + "<br/>");
}
case 2:
{
document.write(2 + "<br/>");
}
break;
case 3:
{
document.write(3 + "<br/>");
}
break;
default:
{
document.write("default <br/>");
}
}
function isInteger(num) {
var result = false;
result = (parseInt(num) == parseFloat(num));
if (result) {
document.write(num + " is an integer" + "<br/>");
}
else {
document.write(num + " is not an integer" + "<br/>");
}
return result;
}
isInteger(15);
isInteger(15.15);
function printDaffodilNumber() {
document.write("Print out all daffodil number: " + "<br/>");
for (var num = 100; num < 1000; ++num) {
var unitsDigit = num % 10;
var tensDigit = parseInt((num / 10) % 10);
var hundredsDigit = parseInt(num / 100);
var sum = Math.pow(unitsDigit, 3)
+ Math.pow(tensDigit, 3)
+ Math.pow(hundredsDigit, 3);
if (sum == num) {
document.write(num + "<br/>");
}
}
}
printDaffodilNumber();
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script>
</script>
</head>
<body>
<script>
</script>
</body>
</html>