review update · foocoding/JavaScript3@e4803e2 · GitHub
Skip to content

Commit e4803e2

Browse files
committed
review update
1 parent 34c3461 commit e4803e2

5 files changed

Lines changed: 97 additions & 26 deletions

File tree

Week1/REVIEW.md

Lines changed: 43 additions & 5 deletions

Week2/MAKEME.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Homework Week 2
22

3+
>[Here](https://github.com/HackYourFuture/JavaScript/tree/master/Week2/README.md) you find the readings you have to complete before the third lecture.
4+
35
### Step 1: Recap/Read
46

57
- Have a look at [The Secret Life of JavaScript Primitives](https://javascriptweblog.wordpress.com/2010/09/27/the-secret-life-of-javascript-primitives/)
@@ -49,7 +51,9 @@ if (3 == 3) {
4951

5052
11. What if you add one more vehicle to the list, can you have that added to the advertisement without changing the code for question 8?
5153

52-
12. Create a function that takes two objects as parameters and compares them. You will actually need to write two functions — one that compares with `==` and one that compares with `===`. Remember that objects can have objects inside of them so you'll need to find a way to compare every element of every object (types and values). For example:
54+
12. Create an empty object
55+
56+
13. Create a function that takes two objects as parameters and compares them. You will actually need to write two functions — one that compares with `==` and one that compares with `===`. Remember that objects can have objects inside of them so you'll need to find a way to compare every element of every object (types and values). For example:
5357

5458
```js
5559
var obj1 = {
@@ -73,7 +77,7 @@ if (3 == 3) {
7377

7478
Note: give this exercise your best shot but don’t spend more than, say, one hour on it.
7579

76-
13. We saw that we can pass functions as arguments to other functions. Your task is to write a function that takes another function as an argument and runs it.
80+
14. We saw that we can pass functions as arguments to other functions. Your task is to write a function that takes another function as an argument and runs it.
7781

7882
```js
7983
function foo(func) {
@@ -88,7 +92,7 @@ if (3 == 3) {
8892
```
8993

9094

91-
14. Write some code to test two arrays for equality using `==` and `===`. Test the following:
95+
15. Write some code to test two arrays for equality using `==` and `===`. Test the following:
9296

9397
```js
9498
var x = [1,2,3];
@@ -106,7 +110,7 @@ Check out this [Fiddle](http://jsfiddle.net/jimschubert/85M4z/). You need to ope
106110
More insights from this [Stack Overflow question](http://stackoverflow.com/questions/22395357/how-to-compare-two-arrays-are-equal-using-javascript).
107111

108112

109-
14. Take a look at the following code:
113+
16. Take a look at the following code:
110114

111115
```js
112116
var o1 = { foo: 'bar' };
@@ -119,6 +123,12 @@ More insights from this [Stack Overflow question](http://stackoverflow.com/quest
119123

120124
Does the order that you assign (`o3 = o2` or `o2 = o3`) matter? {Jim Cramer: ???}
121125

126+
17. What does the following code return? (And why?)
127+
```js
128+
let bar = 42;
129+
typeof typeof bar;
130+
```
131+
122132

123133
> ‘Coerce' means to try to change - so coercing `var x = '6'` to number means trying to change the type to number temporarily.
124134

Week2/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ In week three we will discuss the following topics:
1313
### Here are resources that we like you to read as a preparation for the coming lecture.
1414

1515
- Closures: http://javascriptissexy.com/understand-javascript-closures-with-ease/
16+
- https://developer.mozilla.org/en/docs/Web/JavaScript/Closures
1617
- [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype)
1718

19+
1820
Refresher:
1921
* Objects (*important to really understand them, read this if you are unsure! You may also read chapters 72, 73 and 74 if you have time and want to learn more*):</br>
2022
Chapters 70-71, 75

Week2/REVIEW.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
```
44
This review covers:
5+
• Recap Logical operators
6+
• Typeof
57
• Loops (for/while)
68
• Functions
79
• Advanced data types [Objects]
@@ -31,6 +33,27 @@ This review covers:
3133
|0|0|1|
3234
|1|1|1|
3335

36+
So you can say that false in combination with `&&` always returns true
37+
```js
38+
true && false //-> false
39+
false && true //-> false
40+
false || true //-> true
41+
true || false //-> true
42+
```
43+
44+
### Typeof
45+
46+
`typeof` always returns the data type in a string.
47+
48+
So for example:
49+
```js
50+
let bar = 42;
51+
typeof bar //-> 'number'
52+
typeof typeof bar; //-> 'string'
53+
```
54+
55+
So the data type of what `typeof` returns is always a string, bar on the other hand is still a number.
56+
3457
## Objects
3558

3659
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".

Week3/MAKEME.md

Lines changed: 15 additions & 17 deletions

0 commit comments

Comments
 (0)