-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathscript.js
81 lines (61 loc) · 1.73 KB
/
script.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
// BASIC OPERATORS
// Math Operations
/*
const dob = 2021;
const ageEke = dob - 1997;
const ageSarah = dob - 2010;
console.log(ageEke, ageSarah);
console.log(ageEke * 2, ageSarah / 10, 2 ** 3);
// 2 ** 3 means 2 raised to the power of 3 = 2 * 2 * 2
const firstName = "Victor";
const lastName = "Eke";
console.log(firstName + " " + lastName);
// Typeof operators
console.log(typeof firstName);
// Assignment operators
let x = 10 + 5; // 15
x += 10; // x = x + 10 = 25
x *= 4; //x = x * 4 = 100
x++; // x = x + 1
x--; // x = x - 1
x--; // x = x - 1
console.log(x);
// Comparison operators
console.log(ageEke > ageSarah); // >, <, >=, <=
console.log(ageSarah >= 10);
const isFullAge = ageSarah >= 10;
console.log(dob - 1991 > dob - 2010);
*/
// Maths Operators
const now = 2037;
const ageEke = now - 1997;
const ageSarah = now - 2018;
// log multiple items together.
console.log(ageEke, ageSarah);
console.log(ageEke * 2, ageEke / 10, 2 ** 3);
// 2 ** 3 means 2 to the power of 3 = 2 * 2 *2
// Arithimetic operator
const firstName = "Victor";
const lastName = "Eke";
console.log(firstName + lastName);
// Add space between strings
console.log(firstName + " " + lastName);
// Typeof Operator
// let ageEke = 32;
// console.log(typeof ageEke);
// Equal operator: the equals symbol is an operator on it's own.
// Assignment operators
let x = 10 + 5; // x = 15
x += 10; // x = x + 10 = 25
x *= 4; // x = x * 4 = 100
x++; // x = x + 1;
x--; // x = x - 1;
console.log(x);
// Comparison operators
console.log(ageEke > ageSarah);
console.log(ageSarah >= 18);
console.log(ageSarah <= 18);
// Add the previous calculation to a variable.
const fullAge = ageSarah >= 18;
// We can do all the previous calculation in one line
console.log(now - 1997 > now - 2018);