Showing
18 changed files
with
272 additions
and
0 deletions
1 | +var a = 33; | ||
2 | +var b = 10; | ||
3 | +var c = "Test"; | ||
4 | +console.log("a + b = "); | ||
5 | +result = a + b; | ||
6 | +console.log(result); | ||
7 | + | ||
8 | +console.log("a - b = "); | ||
9 | +result = a - b; | ||
10 | +console.log(result); | ||
11 | +console.log("a / b = "); | ||
12 | +result = a / b; | ||
13 | +console.log(result); | ||
14 | +console.log("a % b = "); | ||
15 | +result = a % b; | ||
16 | +console.log(result); | ||
17 | +console.log("a + b + c = "); | ||
18 | +result = a + b + c; | ||
19 | +console.log(result); | ||
20 | +a = a++; | ||
21 | +console.log("a++ = "); | ||
22 | +result = a++; | ||
23 | +console.log(result); | ||
24 | +b = b--; | ||
25 | +console.log("b-- = "); | ||
26 | +result = b--; | ||
27 | +console.log(result); |
1 | +var a = 33; | ||
2 | +var b = 10; | ||
3 | +console.log("Value of a => (a = b) => "); | ||
4 | +result = (a = b); | ||
5 | +console.log(result); | ||
6 | +console.log("Value of a => (a += b) => "); | ||
7 | +result = (a += b); | ||
8 | +console.log(result); | ||
9 | +console.log("Value of a => (a -= b) => "); | ||
10 | +result = (a -= b); | ||
11 | +console.log(result); | ||
12 | +console.log("Value of a => (a *= b) => "); | ||
13 | +result = (a *= b); | ||
14 | +console.log(result); | ||
15 | +console.log("Value of a => (a /= b) => "); | ||
16 | +result = (a /= b); | ||
17 | +console.log(result); | ||
18 | +console.log("Value of a => (a %= b) => "); | ||
19 | +result = (a %= b); | ||
20 | +console.log(result); |
1 | +var a = 2; // Bit presentation 10 | ||
2 | +var b = 3; // Bit presentation 11 | ||
3 | +console.log("(a & b) => "); | ||
4 | +result = (a & b); | ||
5 | +console.log(result); | ||
6 | + | ||
7 | +console.log("(a | b) => "); | ||
8 | +result = (a | b); | ||
9 | +console.log(result); | ||
10 | + | ||
11 | +console.log("(a ^ b) => "); | ||
12 | +result = (a ^ b); | ||
13 | +console.log(result); | ||
14 | + | ||
15 | +console.log("(~b) => "); | ||
16 | +result = (~b); | ||
17 | +console.log(result); | ||
18 | + | ||
19 | +console.log("(a << b) => "); | ||
20 | +result = (a << b); | ||
21 | +console.log(result); | ||
22 | + | ||
23 | +console.log("(a >> b) => "); | ||
24 | +result = (a >> b); | ||
25 | +console.log(result); |
1 | +var a = 10; | ||
2 | +var b = 20; | ||
3 | +console.log("(a == b) => "); | ||
4 | +result = (a == b); | ||
5 | +console.log(result); | ||
6 | + | ||
7 | +console.log("(a < b) => "); | ||
8 | +result = (a < b); | ||
9 | +console.log(result); | ||
10 | +console.log("(a > b) => "); | ||
11 | +result = (a > b); | ||
12 | +console.log(result); | ||
13 | +console.log("(a != b) => "); | ||
14 | +result = (a != b); | ||
15 | +console.log(result); | ||
16 | +console.log("(a >= b) => "); | ||
17 | +result = (a >= b); | ||
18 | +console.log(result); | ||
19 | +console.log("(a <= b) => "); | ||
20 | +result = (a <= b); | ||
21 | +console.log(result); |
1 | +var age = 20; | ||
2 | +if( age > 18 ) { | ||
3 | + console.log("Qualifies for driving"); | ||
4 | +} | ||
5 | + | ||
6 | +var age = 15; | ||
7 | +if( age > 18 ) { | ||
8 | + console.log("Qualifies for driving"); | ||
9 | +} else { | ||
10 | + console.log("Does not qualify for driving"); | ||
11 | +} | ||
12 | + | ||
13 | + | ||
14 | +var book = "maths"; | ||
15 | +if( book == "history" ) { | ||
16 | + console.log("History Book"); | ||
17 | +} else if( book == "maths" ) { | ||
18 | + console.log("Maths Book"); | ||
19 | +} else if( book == "economics" ) { | ||
20 | + console.log("Economics Book"); | ||
21 | +} else { | ||
22 | + console.log("Unknown Book"); | ||
23 | +} |
1 | +var grade='A'; | ||
2 | +console.log("Entering switch block"); | ||
3 | + | ||
4 | +switch (grade) | ||
5 | +{ | ||
6 | + case 'A': | ||
7 | + console.log("Good job"); | ||
8 | + break; | ||
9 | + | ||
10 | + case 'B': | ||
11 | + console.log("Pretty good"); | ||
12 | + break; | ||
13 | + | ||
14 | + case 'C': | ||
15 | + console.log("Passed"); | ||
16 | + break; | ||
17 | + | ||
18 | + case 'D': | ||
19 | + console.log("Not so good"); | ||
20 | + break; | ||
21 | + | ||
22 | + case 'F': console.log("Failed"); | ||
23 | + break; | ||
24 | + | ||
25 | + default: | ||
26 | + console.log("Unknown grade") | ||
27 | +} | ||
28 | + | ||
29 | +console.log("Exiting switch block"); | ||
30 | + | ||
31 | + | ||
32 | + | ||
33 | +switch (grade) | ||
34 | +{ | ||
35 | + case 'A': | ||
36 | + console.log("Good job"); | ||
37 | + | ||
38 | + case 'B': | ||
39 | + console.log("Pretty good"); | ||
40 | + | ||
41 | + case 'C': | ||
42 | + console.log("Passed"); | ||
43 | + | ||
44 | + case 'D': | ||
45 | + console.log("Not so good"); | ||
46 | + | ||
47 | + case 'F': | ||
48 | + console.log("Failed"); | ||
49 | + | ||
50 | + default: | ||
51 | + console.log("Unknown grade"); | ||
52 | + | ||
53 | +} | ||
54 | + | ||
55 | +console.log("Exiting switch block"); |
1 | +var name = "Ali"; | ||
2 | +var money; | ||
3 | +money = 2000; | ||
4 | + | ||
5 | +console.log("my name is " + name); | ||
6 | +console.log("my money is " + money); | ||
7 | + | ||
8 | +var myVar = "global"; // Declare a global variable | ||
9 | +function checkscope( ) { | ||
10 | + var myVar = "local"; | ||
11 | + // Declare a local variable | ||
12 | + console.log("print myVar " + myVar); | ||
13 | +} | ||
14 | + | ||
15 | +console.log("print myVar " + myVar); | ||
16 | +checkscope(); |
1 | +var count = 0; | ||
2 | +console.log("Starting Loop "); | ||
3 | + | ||
4 | +while (count < 10) { | ||
5 | + console.log("Current Count : " + count); | ||
6 | + count++; | ||
7 | +} | ||
8 | +console.log("Loop stopped!"); | ||
9 | + | ||
10 | + | ||
11 | +var count = 0; | ||
12 | +console.log("Starting Loop"); | ||
13 | +do { | ||
14 | + console.log("Current Count : " + count); | ||
15 | + count++; | ||
16 | +} while (count < 5); | ||
17 | +console.log ("Loop stopped!"); |
1 | +function addPrice(amount) { | ||
2 | + this.price = amount; | ||
3 | +} | ||
4 | +function book(title, author) { | ||
5 | + this.title = title; | ||
6 | + this.author = author; | ||
7 | + this.addPrice = addPrice; | ||
8 | +} | ||
9 | + | ||
10 | +var bookList = new Array(new book("Perl1", "Mohtashim"),new book("Smith", "Mohtashim"),new book("Carl", "Mohtashim"),new book("Perl2", "Mohtashim")); | ||
11 | + | ||
12 | +console.log(bookList); | ||
13 | +console.log("After Sorting"); | ||
14 | +//bookList.sort(sortBook); | ||
15 | +console.log(bookList); |
LectureNotes/Chapter07.pdf
0 → 100755
No preview for this file type
LectureNotes/Experiments07.pdf
0 → 100755
No preview for this file type
-
Please register or login to post a comment