-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperators.js
More file actions
63 lines (50 loc) · 1.03 KB
/
Copy pathoperators.js
File metadata and controls
63 lines (50 loc) · 1.03 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
// An operator is a way to compare or manipulate two
// or more pieces of data
// Math operators
1 + 1
2 - 2
3 * 3
4 / 4
// ** is exponent, or in this case, squaring
5 ** 2
// This is the square root
4 ** .5
// This is the remainder
4 % 3
// Comparison Operators
1 > 0
2 < 3
1 <= 1
1 >= 1
// Why 3 equal signs?
// 1 equal is for variables
// 2 equals is for
3 === 3
3 !== 3
// Logical Operators
&&
is and ||
is or!is not
// With && both need to be true
if (x > 10 && x < 20)
// With || only 1 needs to be true
if (x.even || x > 2)
// With ! the condition needs to be false
if (!x > 2)
// Compound operators only work on variables
// This would not work 1--
// This works
let number2 = 1
// Increment
number2++
// Decrement
number2--
// Change operators also only work with variables
number += 2
// Same as number = number + 2
number -= 2
// Same as number = number - 2
number *= 2
// Same as number = number * 2
number /= 2
// Same as number = number / 2