-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChapter-1.js
More file actions
122 lines (77 loc) · 1.81 KB
/
Copy pathChapter-1.js
File metadata and controls
122 lines (77 loc) · 1.81 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
(a = ((b) * (2)));
/*expression and a statement created
two is a literal value, b is an identifier/variable, a is a variable
right side is the source and left side is the target; creates an assignment statement*/
((a) = ((b) * (2)) + ((foo)(((c) * (3))))
a = b * 2 + foo(c * 3);
a = b * (2 + foo(c * 3));
a = (b * 2) + foo(c * 3);
/*set the variable a to the value 2 - high high level
a = 2 - high level
mov2,2 - low level
100010011 - lowest level
javascript gets compiled for error checking */
a = a + 2;
a += 2;
42;
"42";
"42"[0] //"4";
"abc"[1]; // b
a = 42;
console.log(a);
a = 42;
a/=42;
a = String(a);
console.log(a);
a = 42
b = (a /= 2);
b = Number(b);
console.log(b);
a = 42;
a /= 2;
a = a + ""; //a plus an empty string; string concatunation instead of math. Makes this statemnt into a string using String(a)
console.log(a);
const a = 42; // make a variable that can't be changed later
// Add comments to your code; Explain WHY things are there. Sometimes HOW but never WHAT.
/* Use this
to add
more comment lines
*/
a = 42; // hasn't been formally declared; a bad idea in your code.
var a; // formally declare your variables
a = 42;
function a() {}; // another way to formlly delcare a variable
// This is not a loop, the if statement is only checked and run once
var a;
var foo;
a = 100;
if (a > 10) {
foo = (a + 5);
}
console.log(foo);
// a block is a pairing of statements that get run together
{
var a = 42;
foo(a/2);
}
var a = 42;
var foo;
if ( a > 10) {
a = 10;
foo = (a/2);
}
console.log(foo);
// conditional statements
var a = 10;
if (a > 5) {
a = a * 2;
}
/*falsy values
0 -0 NaN "" false null undefined
*/
var a = 25;
if (a) { // conditional decision based on whether it's true or false
a = a * 2;
}
console.log(a);
void // everything you give void is undefined including zero