-
Notifications
You must be signed in to change notification settings - Fork 0
/
lesson-one-Variables.js
109 lines (55 loc) · 1.35 KB
/
lesson-one-Variables.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// First JavaScript Code
//console.log('Hello Pbody');
// names cannot be reserved keywords
// Cannot start with a number
// Cannot contain a space or hyphen
// Case Sensitive
/*
let name = 'Mosh'; // string literal
let age = 29.01; // number literal
let isApproved = true; // Boolean literall=
let firstName = undefined;
let selectedColour = null;
*/
// Assinging a "Person" as an Object:
let person = {
name: 'Leon',
age: 29
}; // Object literal
console.log(name);
console.log(person);
// Dot Notation:
person.name = 'Jeff';
console.log(person.name);
// Bracket Noation:
let selection = 'age'; // This could be changed in runtime
// to select different variable for the next line
person[selection] = 'Alice';
console.log(person['name']);
console.log(person);
// Using ARRAYs
let selectedColors = ['red', 'blue']; // array Literal
console.log(selectedColors);
console.log(selectedColors[0]);
selectedColors[2] = '1';
console.log(selectedColors.length);
// Allowed
// let firstName, lastname;
// let givenName = 'Leon', sirName;
// Better
let userName = 'PanGalactic';
let nickName = 'Leon';
let interestRate = 0.3;
interestRate = 1;
console.log(interestRate);
// Types:
//Primitives:
// String
// number
// Boolean
// Undefined
// null
// Reference Types
// Objects
// Array
// Functions