-
Notifications
You must be signed in to change notification settings - Fork 0
/
operations.js
81 lines (57 loc) · 1.84 KB
/
operations.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
/* Maths operators
Multiply --> *
Divide --> /
Exponents --> **
Modulo/ Remainder --> %
Add --> +
Subtract --> -
*/
num1 = 6
num2 = 2
// ***********************************Multiply*********************************************************
mul = num1 * num2
console.log(mul)
// ***********************************Divide************************************************************
div = num1/num2
console.log(div)
// ***********************************Exponents***********************************************************
modulo = num1 % num2
console.log(modulo)
// ***********************************Multiply***********************************************************
add = num1 + num2
console.log(add)
// ***********************************Multiply***********************************************************
subtract = num1 - num2
console.log(subtract)
/* MATHS METHODS
floor --> Rounds down
ceil --> Rounds up
random() --> gives the random number between 0 and 1
*/
/*
Math.floor(100.25)
// output - 100 (Rounding down)
Math.ceil(100.25)
// output - 101 (Rounding up)
*/
console.log(Math.floor(100.25))
console.log(Math.ceil(100.25))
console.log(Math.random())
//conditional operators
/* == ---> double equal means is equal to (with type correction)
=== ---> triple equal means is equal to (strict equality: no type correction)
> ----> greater than
< -----> less than
>= -------> greater than equal to
<= ---------> less than equal to
!= -----------> not equal to (with type correction)
!== ------------> not equal to (without type correction)
*/
console.log(2 == "2")
// It will print true because of type correction
console.log(2 === "2")
//It will print false because it does not support type correction
console.log(2!="2")
// It will print false beacuse of type correction
console.log(2!=="2")
// It will Print True because it does not support type correction