Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8f769b9

Browse files
committed
updated review week1
1 parent 995d94f commit 8f769b9

File tree

8 files changed

+219
-70
lines changed

8 files changed

+219
-70
lines changed

Week0/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ In week one we will discuss the following topics:
66
• Intro JavaScript (What is it, where can you use it for)
77
• Variables [var, let, const]
88
• Basic Data types [Strings, Numbers, Arrays]
9+
• Operators
910
```
1011

1112
### Here are resources that we like you to read as a preparation for the coming lecture:

Week1/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ In week two we will discuss the following topics:
1414

1515
- 'Functions' of _A Smarter Way To Learn JavaScript_ : Chapters 35 - 38
1616
- Functions ~ http://eloquentjavascript.net/03_functions.html
17+
- 'Objects' of _A Smarter Way To Learn JavaScript_ : Chapters 35 - 38
18+
- 'Conditions' of _A Smarter Way To Learn JavaScript_ : Chapters 35 - 38
1719
- Program structure ~ http://eloquentjavascript.net/02_program_structure.html
1820

1921
_Please go through the material and come to class prepared!_

Week1/REVIEW.md

Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# REVIEW JavaScript Basics week 1
22

3+
```
4+
This review covers:
5+
• some commands thought by Unmesh in class today :white_check_mark:
6+
• Intro JavaScript (What is it, where can you use it for)
7+
• Variables [var, let, const] :white_check_mark:
8+
• Basic Data types [Strings, Numbers, Arrays] :white_check_mark:
9+
• Operators
10+
```
11+
312
## CLI
413
```
514
pwd : present working directory
@@ -33,6 +42,12 @@ man <COMMAND> : Display manual of the COMMAND
3342

3443
A "variable" is a place where you can store information, such as a string, or a number. New variables in JavaScript are declared using one of three keywords: let, const, or var.
3544

45+
> Think of variables names like **labels** on boxes, while the value of the variable are the **contents** of the box - you could change the contents of a box and leave the label intact, the contents of the boxes can have different types, the boxes should have good labels (a box of books being labeled pens would be very confusing),
46+
>
47+
![Variables are like boxes](./assets/box.png)
48+
> Photo from [Khan Academy](http://cs-blog.khanacademy.org/2013/09/teaching-variables-analogies-and.html)
49+
50+
3651
### Variable declaration
3752

3853
Variables are "declared" using the `var`, `let` or `const` keyword:
@@ -62,8 +77,6 @@ foo = 4; // change variable `foo`
6277
```
6378

6479

65-
Basic Data types [Strings, Numbers, Arrays]
66-
6780
## Variable types
6881

6982
All variables have a type. In our example above, the variable `x` is a `number`. JavaScript supports the following types:
@@ -105,6 +118,13 @@ let x;
105118
console.log(typeof x); // -> "undefined"
106119
```
107120

121+
## Strings
122+
123+
>TODO
124+
125+
## Numbers
126+
127+
>TODO
108128
109129
## Arrays
110130

@@ -131,14 +151,84 @@ console.log(arr[a]); // -> jane
131151

132152
If the index you use is not an integer (a whole number), or if it's less than `0` or if it's greater than or equal to the array's length, you will get back `undefined`.
133153

154+
More about [arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
134155

135-
### 2.3 Basic operators
156+
### Comparison operators
136157

137158
>Note the two different uses of the equals sign:
138159
A single equals sign (=) is used to assign a value to a variable.
139160
A triple equals sign (===) is used to compare two values (see Equality Operators).
140161

141-
### 2.5 Operator precedence
162+
#### Equality operators
163+
* Equality `==`
164+
* Inequality `!=`
165+
* Identity / strict equality `===`
166+
* Non-identity / strict inequality `!==`
167+
168+
How does this work in practice?
169+
170+
```js
171+
1 == 1 // true
172+
7 == '7' // true
173+
1 != 2 // true
174+
5 === 5 // true
175+
9 === '9' // false
176+
3 !== 3 // true
177+
3 !== '3' // true
178+
```
179+
180+
> why does `7 == '7'` returns true and `9 === '9'` returns false?
181+
182+
#### Relational operators
183+
* Greater than operator `>`
184+
* Greater than or equal operator `>=`
185+
* Less than operator `<`
186+
* Less than or equal operator `<=`
187+
188+
```js
189+
4 > 3 // returns true
190+
3 >= 3 // returns true
191+
13 < 12 //returns false
192+
3 <= 4 // returns true
193+
```
194+
195+
More about [comparison operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators)
196+
197+
### Arithmetic operators
198+
199+
* Addition `+`
200+
* Subtraction `-`
201+
* Multiplication `*`
202+
* Division `/`
203+
* Remainder (sometimes called modulo) `%`
204+
<br>Returns the remainder left over after you've shared the left number out into a number of integer portions equal to the right number.
205+
206+
```js
207+
8 + 9 //returns 17, adds two numbers together.
208+
20 - 12 //returns 8, subtracts the right number from the left.
209+
3 * 4 //returns 12, multiplies two numbers together.
210+
10 / 5 //return 2, divides the left number by the right.
211+
8 % 3 //returns 2, as three goes into 8 twice, leaving 2 left over.
212+
```
213+
214+
More about [Arithmetic_Operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#.25_.28Modulus.29)
215+
216+
### Logical operators
217+
218+
* AND `&&`
219+
* OR `||`
220+
* NOT `!`
221+
222+
Given that x = 6 and y = 3
223+
```js
224+
x < 10 && y > 1 // returns true
225+
x == 5 || y == 5 // returns false
226+
x !== y // returns true
227+
```
228+
229+
More about [logical operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators)
230+
231+
### Operator precedence
142232

143233
There are compound assignment operators such as +=. The following two assignments are equivalent:
144234

Week1/assets/box.png

34.6 KB
Loading

Week2/MAKEME.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ More insights from this [Stack Overflow question](http://stackoverflow.com/quest
9090

9191
### Step 2: **Some freeCodeCamp challenges:**
9292

93-
1.. [Comparisons with the Logical And Operator](https://www.freecodecamp.com/challenges/comparisons-with-the-logical-and-operator)
93+
1. [Comparisons with the Logical And Operator](https://www.freecodecamp.com/challenges/comparisons-with-the-logical-and-operator)
9494

9595
2. [Record Collection](https://www.freecodecamp.com/challenges/record-collection)
9696

Week2/REVIEW.md

Lines changed: 108 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,15 @@
11
# REVIEW JavaScript week 2
22

3-
## Statements & expressions
4-
5-
Most programming languages that you'll encounter in real life are called "imperative" programming languages. JavaScript is such an imperative programming language. Imperative is another word for command-like. That is, you give the computer a bunch of commands after each other. First do this, then do that, etc.
6-
7-
These individual commands are called "statements" in imperative programming languages. You can compare them with sentences in the English language. They have a use by themselves, and do not need something else. "The man eats bread." is a full sentence, it conveys a meaning by itself. A sentence in English is always terminated by a period.
8-
9-
Similarly, a statement in JavaScript should provide a command by itself. JavaScript-statements are (almost always) terminated by a semicolon.
10-
11-
This is a complete statement:
12-
13-
```js
14-
let s = "HackYourFuture";
15-
```
16-
17-
It is a full command: declare a variable `s` and initialize it with `"HackYourFuture"`. JavaScript doesn't need any other information to know what we want. The statement is terminated with a semicolon.
18-
19-
However, this is not a complete statement:
20-
21-
```js
22-
4 + 5
23-
```
24-
25-
This equals `9`, but what is JavaScript to do with it? It doesn't provide a command. You'd need to do something with it, e.g. `var x = 4 + 5;` or `callFunction(4 + 5)`. We call these parts of statements "expressions". Expressions are not terminated by semicolons. Expressions always "evaluate into a value". In our example, the expression `4 + 5` "evaluates into `9`". If expressions cannot be evaluated into a value, they are invalid. For instance, `4 +` is not a valid expression, it is incomplete, because we need something else after the plus sign.
26-
27-
So, statements can *contain* expressions. Can expressions contain statements? No, they cannot. However, they can themselves contain expressions. Think about `4 + 5`: it contains the expressions `4` and `5`, as these both evaluate into a value: the expression `4` evaluates into the number `4`, it is a very simple expression. Similarly, `true`, `null`, `undefined` are all expressions.
28-
29-
### Examples of expressions
30-
31-
Here are some examples of expressions. Remember: expressions evaluate into a value, but do not provide a command:
32-
33-
* `sum(a, b)`
34-
* `a`
35-
* `a > 4 ? "yes" : "no"`
36-
* `a + b`
37-
* `a && b || c`
38-
* `arr.length`
39-
* `obj["name"]`
40-
* `[1, 2, 3]`
41-
* `arr[1]`
42-
* `[1]` (this is an array with one element!)
43-
* `function a() { return 4; }`
44-
45-
The last one requires a bit of explanation. If you write:
46-
47-
```js
48-
function a() { return 4; }
493
```
50-
51-
by itself, this is a *statement* (a function declaration statement). However, if you write it as part of a statement, such as:
52-
53-
```js
54-
let b = function a() { return 4; }
4+
This review covers:
5+
• Loops (for/while)
6+
• Functions :white_check_mark:
7+
• Advanced data types [Objects] :white_check_mark:
8+
• Conditions
9+
• Statements vs Expressions :white_check_mark:
10+
• Naming conventions
5511
```
5612

57-
now it is an expression. This is an exceptional situation where something can be a statement or an expression.
58-
59-
### Examples of not-expressions
60-
61-
The following are not expressions:
62-
63-
* `var` -> this is a keyword, see below
64-
* `var x;` -> this is a statement
65-
* `+` -> this is only an operator
66-
* `if (a > 4) { return "yes"; } else { return "no"; }`
67-
68-
`if` is also a statement. However, it is quite a complex statement. It is also referred to as a "construct", just like `for`, `while`, `try`, etc.
69-
7013
## Functions
7114

7215
A function is a reusable piece of code. Functions are *very* important in JavaScript, to the extent that some people call JavaScript a "function-oriented" language. As mentioned above, variables can be of type function. In fact, *every function is a variable*.
@@ -144,3 +87,104 @@ myArray.slice();
14487
myNumber.toString();
14588
...
14689
```
90+
91+
92+
## Objects
93+
94+
Variables that are objects also contain a list of things, but instead of them being in some specific order, they can be assigned to words, called "keys". Instead of "elements" the things that are inside objects are called "properties".
95+
96+
97+
```js
98+
var obj = {name: 'John', age: 24};
99+
```
100+
101+
This object has two properties: `name` and `age`. The "value" of the property `name` is the string `'John'`. The "value" of the property `age` is the number `24`.
102+
103+
When accessing object properties, you can use the dot-notation: `obj.name` or the bracket-notation: `obj["name"]`. Note that the latter looks a lot like the way to access array elements. However, here what's inside the bracket (called "key" for objects, instead of "index") must be a string.
104+
105+
```js
106+
console.log(obj.name); // -> 'John'
107+
console.log(obj['name']); // -> 'John'
108+
```
109+
110+
Just like with arrays, you can also use a variable to access properties, as long as these variables are strings. In this case you cannot use the dot-notation!
111+
112+
```js
113+
var ageKey = 'age';
114+
console.log(obj[ageKey]); // -> 24
115+
```
116+
117+
Remember that there is a very big difference between `obj[name]` and `obj["name"]`.
118+
119+
> Note:
120+
>
121+
> Thinking back of arrays, the length of an array can be retrieved by `arr.length`. So as mentioned before, arrays are just like other JavaScript objects. You could even write `arr['length']` to access the `length` property of the array. JavaScript will look: is what we put between brackets a number? Then it is an index and we'll look up the correct array element. If it's a string, it's a key and we will look up the corresponding property.
122+
123+
124+
## Statements & expressions
125+
126+
Most programming languages that you'll encounter in real life are called "imperative" programming languages. JavaScript is such an imperative programming language. Imperative is another word for command-like. That is, you give the computer a bunch of commands after each other. First do this, then do that, etc.
127+
128+
These individual commands are called "statements" in imperative programming languages. You can compare them with sentences in the English language. They have a use by themselves, and do not need something else. "The man eats bread." is a full sentence, it conveys a meaning by itself. A sentence in English is always terminated by a period.
129+
130+
Similarly, a statement in JavaScript should provide a command by itself. JavaScript-statements are (almost always) terminated by a semicolon.
131+
132+
This is a complete statement:
133+
134+
```js
135+
let s = "HackYourFuture";
136+
```
137+
138+
It is a full command: declare a variable `s` and initialize it with `"HackYourFuture"`. JavaScript doesn't need any other information to know what we want. The statement is terminated with a semicolon.
139+
140+
However, this is not a complete statement:
141+
142+
```js
143+
4 + 5
144+
```
145+
146+
This equals `9`, but what is JavaScript to do with it? It doesn't provide a command. You'd need to do something with it, e.g. `var x = 4 + 5;` or `callFunction(4 + 5)`. We call these parts of statements "expressions". Expressions are not terminated by semicolons. Expressions always "evaluate into a value". In our example, the expression `4 + 5` "evaluates into `9`". If expressions cannot be evaluated into a value, they are invalid. For instance, `4 +` is not a valid expression, it is incomplete, because we need something else after the plus sign.
147+
148+
So, statements can *contain* expressions. Can expressions contain statements? No, they cannot. However, they can themselves contain expressions. Think about `4 + 5`: it contains the expressions `4` and `5`, as these both evaluate into a value: the expression `4` evaluates into the number `4`, it is a very simple expression. Similarly, `true`, `null`, `undefined` are all expressions.
149+
150+
### Examples of expressions
151+
152+
Here are some examples of expressions. Remember: expressions evaluate into a value, but do not provide a command:
153+
154+
* `sum(a, b)`
155+
* `a`
156+
* `a > 4 ? "yes" : "no"`
157+
* `a + b`
158+
* `a && b || c`
159+
* `arr.length`
160+
* `obj["name"]`
161+
* `[1, 2, 3]`
162+
* `arr[1]`
163+
* `[1]` (this is an array with one element!)
164+
* `function a() { return 4; }`
165+
166+
The last one requires a bit of explanation. If you write:
167+
168+
```js
169+
function a() { return 4; }
170+
```
171+
172+
by itself, this is a *statement* (a function declaration statement). However, if you write it as part of a statement, such as:
173+
174+
```js
175+
let b = function a() { return 4; }
176+
```
177+
178+
now it is an expression. This is an exceptional situation where something can be a statement or an expression.
179+
180+
### Examples of not-expressions
181+
182+
The following are not expressions:
183+
184+
* `var` -> this is a keyword, see below
185+
* `var x;` -> this is a statement
186+
* `+` -> this is only an operator
187+
* `if (a > 4) { return "yes"; } else { return "no"; }`
188+
189+
`if` is also a statement. However, it is quite a complex statement. It is also referred to as a "construct", just like `for`, `while`, `try`, etc.
190+

Week3/REVIEW.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# REVIEW JavaScript week 3
2+
3+
```
4+
This review covers:
5+
• More CLI
6+
• Closures
7+
• Scope
8+
• Array Manipulations
9+
• Basic DOM manipulations [img src, innerHTML]
10+
• Code commenting
11+
```
12+

Week8/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Reading material for the ningth lecture:
1+
# Reading material for the ninth lecture:
22

33
```
44
In week nine we will discuss the following topics:

0 commit comments

Comments
 (0)