Dexter Jin

Experiments06 Uploaded

// Please implements multiplication tables (구구단)
var numbers = new Array(12, 45, 2, 31, 4, 56, 6, 7);
// find out maximum number and minimum numbers
for (var index in numbers) {
console.log ("index[" + index +"] = " + numbers[index]);
}
var numbers = new Array (10, 11, 2, 1, 3, 1, 4, 10, 20, 21);
// Sort numbers in ascending order
<html>
<body>
<script type="text/javascript">
<!--
document.write("Hello World");
//-->
</script>
</body>
</html>
console.log("Hello");
console.log("Hello");
console.log("Hello");
console.log("Hello");
console.log("Hello");
var a = 33;
var b = 10;
var c = "Test";
console.log("a + b = ");
result = a + b;
console.log(result);
console.log("a - b = ");
result = a - b;
console.log(result);
console.log("a / b = ");
result = a / b;
console.log(result);
console.log("a % b = ");
result = a % b;
console.log(result);
console.log("a + b + c = ");
result = a + b + c;
console.log(result);
a = a++;
console.log("a++ = ");
result = a++;
console.log(result);
b = b--;
console.log("b-- = ");
result = b--;
console.log(result);
var a = 33;
var b = 10;
console.log("Value of a => (a = b) => ");
result = (a = b);
console.log(result);
console.log("Value of a => (a += b) => ");
result = (a += b);
console.log(result);
console.log("Value of a => (a -= b) => ");
result = (a -= b);
console.log(result);
console.log("Value of a => (a *= b) => ");
result = (a *= b);
console.log(result);
console.log("Value of a => (a /= b) => ");
result = (a /= b);
console.log(result);
console.log("Value of a => (a %= b) => ");
result = (a %= b);
console.log(result);
var a = 2; // Bit presentation 10
var b = 3; // Bit presentation 11
console.log("(a & b) => ");
result = (a & b);
console.log(result);
console.log("(a | b) => ");
result = (a | b);
console.log(result);
console.log("(a ^ b) => ");
result = (a ^ b);
console.log(result);
console.log("(~b) => ");
result = (~b);
console.log(result);
console.log("(a << b) => ");
result = (a << b);
console.log(result);
console.log("(a >> b) => ");
result = (a >> b);
console.log(result);
var a = 10;
var b = 20;
console.log("(a == b) => ");
result = (a == b);
console.log(result);
console.log("(a < b) => ");
result = (a < b);
console.log(result);
console.log("(a > b) => ");
result = (a > b);
console.log(result);
console.log("(a != b) => ");
result = (a != b);
console.log(result);
console.log("(a >= b) => ");
result = (a >= b);
console.log(result);
console.log("(a <= b) => ");
result = (a <= b);
console.log(result);
var a = 10;
var b = 20;
var linebreak = "<br />";
console.log ("((a > b) ? 100 : 200) => ");
result = (a > b) ? 100 : 200;
console.log(result);
console.log ("((a < b) ? 100 : 200) => ");
result = (a < b) ? 100 : 200;
console.log(result);
var numbers = new Array(1,2,2,3,4)
for (var num in numbers) {
// key and Value
console.log(num + " = " + numbers[num]);;
}
console.log ("Exiting from the loop!");
var age = 20;
if( age > 18 ) {
console.log("Qualifies for driving");
}
var age = 15;
if( age > 18 ) {
console.log("Qualifies for driving");
} else {
console.log("Does not qualify for driving");
}
var book = "maths";
if( book == "history" ) {
console.log("History Book");
} else if( book == "maths" ) {
console.log("Maths Book");
} else if( book == "economics" ) {
console.log("Economics Book");
} else {
console.log("Unknown Book");
}
var a = true;
var b = false;
console.log("(a && b) => ");
result = (a && b);
console.log(result);
console.log("(a || b) => ");
result = (a || b);
console.log(result);
console.log("!(a && b) => ");
result = (!(a && b));
console.log(result);
var grade='A';
console.log("Entering switch block");
switch (grade)
{
case 'A':
console.log("Good job");
break;
case 'B':
console.log("Pretty good");
break;
case 'C':
console.log("Passed");
break;
case 'D':
console.log("Not so good");
break;
case 'F': console.log("Failed");
break;
default:
console.log("Unknown grade")
}
console.log("Exiting switch block");
switch (grade)
{
case 'A':
console.log("Good job");
case 'B':
console.log("Pretty good");
case 'C':
console.log("Passed");
case 'D':
console.log("Not so good");
case 'F':
console.log("Failed");
default:
console.log("Unknown grade");
}
console.log("Exiting switch block");
var a = 10;
var b = "String";
result = (typeof b == "string" ? "B is String" : "B is Numeric");
console.log("Result => ");
console.log(result);
result = (typeof a == "string" ? "A is String" : "A is Numeric");
console.log("Result => ");
console.log(result);
var name = "Ali";
var money;
money = 2000;
console.log("my name is " + name);
console.log("my money is " + money);
var myVar = "global"; // Declare a global variable
function checkscope( ) {
var myVar = "local";
// Declare a local variable
console.log("print myVar " + myVar);
}
console.log("print myVar " + myVar);
checkscope();
var count = 0;
console.log("Starting Loop ");
while (count < 10) {
console.log("Current Count : " + count);
count++;
}
console.log("Loop stopped!");
var count = 0;
console.log("Starting Loop");
do {
console.log("Current Count : " + count);
count++;
} while (count < 5);
console.log ("Loop stopped!");