-
Notifications
You must be signed in to change notification settings - Fork 1
/
js_lec_2.js
108 lines (60 loc) · 1.5 KB
/
js_lec_2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//comparision operators
// == used to compare equal values
var a = 20;
var b = 20;
document.write(a == b);
// === used for comparison but
// data type is also checked
var x = 100;
var y = "100";
document.write("<br><br>");
// if/else statement
if(a > b){
document.write("Han a bara he b se");
} else {
document.write("Nahi, a chota he.");
}
// if/else-if statement
if(a > b){
document.write("a is greater than b");
} else if(b > a) {
document.write("b is greater than a");
} else {
document.write("koi condition true nahi he");
}
document.write("<br><br>");
document.write(x == y);
document.write("<br><br>");
document.write(x === y);
// != (not equal to)
document.write("<br><br>");
document.write(a != b);
// !== (not equal to, the data type is also checked)
document.write("<br><br>");
document.write(x !== y);
// > (greater than)
document.write("<br><br>");
document.write(a > b);
// > (less than)
document.write("<br><br>");
document.write(a < b);
document.write("<br><br>");
document.write("The End");
// >= (great than OR equal to)
document.write("<br><br>");
document.write(a >= b);
// <= (less than OR equal to)
// &&, ||, !
document.write("<br><br>");
document.write(a >= b);
// ternoary operator
document.write("<br><br>");
var isAdult;
var age = 50;
isAdult = (age < 18) ? "Too Young" : "Old Enough";
document.write(isAdult);
// String Concatination
document.write("<br><br>");
var firstName = "Shajeel ";
var secondName = "Afzal";
var fullName = firstName + secondName;