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

Skip to content

Commit e4803e2

Browse files
committed
review update
1 parent 34c3461 commit e4803e2

File tree

5 files changed

+97
-26
lines changed

5 files changed

+97
-26
lines changed

Week1/REVIEW.md

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ To get the type of a variable, use the following code:
9595

9696
```js
9797
let x = 5;
98-
let typeOfX = typeof x; // -> "number"
98+
let typeOfX = typeof x; // -> 'number'
9999
```
100100

101101
Note that I've put an asterisk behind 'array'. That is because in JavaScript, array is a special kind of object:
102102

103103
```js
104104
let arr = [1, 2, 3];
105-
let typeOfArr = typeof arr; // -> "object"
105+
let typeOfArr = typeof arr; // -> 'object'
106106
```
107107

108108
However, in our communication, we will call these variables arrays.
@@ -115,16 +115,54 @@ Whenever you declare a variable, but you don't set a value, the variable will be
115115

116116
```js
117117
let x;
118-
console.log(typeof x); // -> "undefined"
118+
console.log(typeof x); // -> 'undefined'
119119
```
120120

121+
122+
### Typeof
123+
124+
You can use `typeof` to get the type of a certain variable as you have seen in the above section 'Variable types'. As you can see in the following examples it returns the type of data that you have stored in your variable.
125+
121126
## Strings
122127

123-
>TODO
128+
In JavaScript you can store a series of characters inside a variable, you then call this a string. You can store all sorts of characters (text/numbers, spaces or phrases) in strings. By using the `''` you define that something is a string. You can also use `""` to create a string. Both are fine as long as you are consistent (just make a choice on which one you prefer and stick to it).
129+
130+
```js
131+
let foo = '42';
132+
typeof foo //-> 'string'
133+
134+
let bar = 'I\'m 99 years old ';
135+
typeof bar //-> 'string'
136+
```
137+
138+
### String indexes and string properties
139+
The index of a string always starts at 0.
140+
Strings also have properties, for example `.length` you can use this to find the length of a string.
141+
142+
So for example:
143+
```js
144+
let baz = 'Hello World';
145+
baz[0]; //-> "H"
146+
baz.length; //-> 11
147+
```
148+
149+
### String methods
150+
151+
>Todo
124152
125153
## Numbers
126154

127-
>TODO
155+
All numbers in JavaScript are considered numbers with or without decimal
156+
157+
```js
158+
let quux = 42;
159+
typeof quux //-> 'number'
160+
161+
let quuux = 3.3333;
162+
typeof quuux //-> 'number'
163+
164+
```
165+
128166

129167
## Arrays
130168

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
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
1-
# Homework Week 3
2-
3-
## Read:
4-
- https://github.com/HackYourFuture/JavaScript/blob/master/Week3/README.md
5-
6-
## Challenges:
7-
- https://www.freecodecamp.com/challenges/declare-javascript-objects-as-variables
8-
- https://www.freecodecamp.com/challenges/make-instances-of-objects-with-a-constructor-function
9-
- https://www.freecodecamp.com/challenges/make-unique-objects-by-passing-parameters-to-our-constructor
10-
- https://www.freecodecamp.com/challenges/make-object-properties-private
11-
12-
Loops practice - https://www.freecodecamp.com/challenges/iterate-with-javascript-for-loops
13-
https://www.freecodecamp.com/challenges/iterate-with-javascript-while-loops
14-
https://developer.mozilla.org/en/docs/Web/JavaScript/Closures
15-
16-
And just for fun ... https://www.freecodecamp.com/challenges/sum-all-numbers-in-a-range
1+
## Homework Week 3
172

3+
>[Here](https://github.com/HackYourFuture/JavaScript/tree/master/Week3/README.md) you find the readings you have to complete before the fourth lecture.
184
5+
### Step 1: Recap/Read
196

7+
### Step 2: Watch
208

21-
## And a custom DOM manipulation challenge :mortar_board:
9+
### Step 3: Custom DOM manipulation challenge :mortar_board:
2210

2311
1. Open a new js file and start by declaring in array with in there 10 strings. These strings should be of book title's you have read (or made up) and be lowercase without spaces or special characters so that you can use these later as Id's. (Example: Harry Potter's - The Chamber of Secrets -> `harry_potter_chamber_secrets`).
2412

@@ -33,3 +21,13 @@ And just for fun ... https://www.freecodecamp.com/challenges/sum-all-numbers-in-
3321
6. Beautify your html page with css, add sources and alts to each of the images.
3422

3523
7. __Optional (expert)__ Download book covers for each book, construct a new Object which has as keys the bookId's again, and as value the path to the image source (e.g. `{"harry_potter_blabla": "./img/harry_potter_blabla.jpg", ...}`). Now loop over these entries (_hint: `Object.keys(objectName)` gives you an array containing the keys_). Then write a function which places an image at the corresponding `li` element. Remember that Objects are not ordered, so you cannot guarantee that the first key is the first `li` element. (_Hint: you could give each `li` item an `id` tag by modifying the function you made before_)
24+
25+
### Step 4: **FreeCodeCamp challenges:**
26+
27+
- https://www.freecodecamp.com/challenges/declare-javascript-objects-as-variables
28+
- https://www.freecodecamp.com/challenges/make-instances-of-objects-with-a-constructor-function
29+
- https://www.freecodecamp.com/challenges/make-unique-objects-by-passing-parameters-to-our-constructor
30+
- https://www.freecodecamp.com/challenges/make-object-properties-private
31+
32+
33+
And just for fun ... https://www.freecodecamp.com/challenges/sum-all-numbers-in-a-range

0 commit comments

Comments
 (0)