-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperator.js
More file actions
108 lines (62 loc) · 1.53 KB
/
operator.js
File metadata and controls
108 lines (62 loc) · 1.53 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Arithmetic operators
let x1 = 10;
let y1 = 20 ;
//increment
//console.log(x++);
// Decrement
//console.log (--x);
// Assignment Operators
let x = 10 ;
x = x + 4 ;
x += 5 ;
console.log (x)
// Realtional Operators
let y = 1 ;
console.log (y > 0);
console.log (y >= 1);
console.log (y < 1);
// Strict Equality types and value
console.log (y === 1); // true
console.log (y !== 1); // false
console.log ('1' === 1);
// Lose Equality Operators
console.log ('1' == 1);
console.log (true == 1 )
// ternary operators
let points = 110;
let type = points > 100 ? 'Silver' : 'Gold';
let marks = 90 ;
let grade = marks > 100 ? 'A': 'B';
console.log (grade)
// Logocal operators
let highIncom = false ;
let goodCreditScore = false ;
//let eligibleForLoan = highIncom && goodCreditScore ;
let eligibleForLoan = highIncom || goodCreditScore ;// Both are true
console.log ("eligible", eligibleForLoan)
let applicationRefused = !eligibleForLoan ;
console.log (eligibleForLoan) ;
// if the
let userColor ;
let defaultColor = "blue" ;
let currentColor = userColor || defaultColor ;
if (userColor == undefined ){
console.log (currentColor);
}
// Precdence
//let a = 2 + 3 * 4; // First multiplication is run then addition
//console.log (a);
// swapping two values
let a = "red";
let b = "blue";
c = a ;
a = b ;
b = c ;
console.log (b , a);
// swapping two values without third variable
let a = 4 ;
let b = 8 ;
a = a + b // 8 + 4 = 12
b = a - b // 12 - 8 = 4
a = a - b // 12 - 4 = 8
console.log (a);