You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-4Lines changed: 3 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,11 @@
1
-
> Please help us improve and share your feedback! If you find better tutorials or links, please share them by opening a Pull Request.
2
1
3
-
# Hack Your JavaScript
2
+
# Hack Your JavaScript — Class 10
4
3
Here you can find course content and homework for the JavaScript 1,2 and 3 modules
5
4
6
5
|Week|Topic|Read|Homework|
7
6
|----|-----|----|--------|
8
-
|0.|Preparation for your first JavaScript session|[Reading Week 0](https://github.com/HackYourFuture/JavaScript/tree/MandT/Week0)|-|
9
-
|1.|• Intro JavaScript (What is it, where can you<br> use it for)<br>• Basic Data types [Strings, Numbers, Arrays]<br>• Variables<br>• Operators<br>• Conditions <br>• Naming conventions|[CLI Reading Week 1](https://github.com/HackYourFuture/CommandLine/blob/MandT/Lecture-1.md)|[Homework Week 1](https://github.com/HackYourFuture/JavaScript/tree/MandT/Week1/MAKEME.md)|
7
+
|0.|Preparation for your first JavaScript session|[Pre-reading](https://github.com/HackYourFuture/JavaScript/tree/MandT/Week0)|-|
8
+
|1.|• Intro JavaScript (What is it, where can you use it for)<br>• Basic Data types [Strings, Numbers, Arrays]<br>• Variables<br>• Operators<br>• Conditions <br>• Naming conventions|[CLI Reading Week 1](https://github.com/HackYourFuture/CommandLine/blob/MandT/Lecture-1.md)|[Homework Week 1](https://github.com/HackYourFuture/JavaScript/tree/MandT/Week1/MAKEME.md)|
1. 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:
4
-
5
-
```js
6
-
var obj1 = {
7
-
a:1,
8
-
b:'this is the letter b',
9
-
c: { foo:'what is a foo anyway',
10
-
bar: [1,2,3,4]
11
-
}
12
-
}
13
-
14
-
var obj2 = {
15
-
a:'1',
16
-
b:'this is the letter b',
17
-
c: { foo:'what is a foo anyway',
18
-
bar: [1,2,3,4]
19
-
}
20
-
}
21
-
```
22
-
23
-
in our example we'll say that obj1 == obj2 is true and obj1 === obj2 is false. Make sure you can see why before you write any code!
24
-
25
-
2. 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.
26
-
27
-
```js
28
-
functionfoo(func) {
29
-
// What to do here?
30
-
}
31
-
32
-
functionbar() {
33
-
console.log('Hello, I am bar!');
34
-
}
35
-
36
-
foo(bar);
37
-
```
38
-
39
-
40
-
Write some code to test two arrays for equality using == and ===. Test the following:
41
-
```
42
-
var x = [1,2,3];
43
-
var y = [1,2,3];
44
-
var z = y;
45
-
```
46
-
What do you think will happen with x == y, x === y and z == y and z == x? Prove it!
Copy file name to clipboardExpand all lines: Week3/MAKEME.md
+85-3Lines changed: 85 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,84 @@
1
-
# Homework Week 3
1
+
# Homework Week 3 (moved over from Week 2)
2
+
3
+
1. 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:
4
+
5
+
```js
6
+
var obj1 = {
7
+
a: 1,
8
+
b: 'this is the letter b',
9
+
c: { foo: 'what is a foo anyway',
10
+
bar: [1,2,3,4]
11
+
}
12
+
}
13
+
14
+
var obj2 = {
15
+
a: '1',
16
+
b: 'this is the letter b',
17
+
c: { foo: 'what is a foo anyway',
18
+
bar: [1,2,3,4]
19
+
}
20
+
}
21
+
```
22
+
23
+
In our example we'll say that `obj1 == obj2` is `true` and `obj1 === obj2` is `false`. Make sure you can see why before you write any code!
24
+
25
+
2. 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.
26
+
27
+
```js
28
+
function foo(func) {
29
+
// What to do here?
30
+
}
31
+
32
+
function bar() {
33
+
console.log('Hello, I am bar!');
34
+
}
35
+
36
+
foo(bar);
37
+
```
38
+
39
+
40
+
Write some code to test two arrays for equality using `==` and `===`. Test the following:
41
+
42
+
```js
43
+
var x = [1,2,3];
44
+
var y = [1,2,3];
45
+
var z = y;
46
+
```
47
+
What do you think will happen with `x == y`, `x === y` and `z == y` and `z == x`? Prove it!
48
+
49
+
> Don't cheat! Seriously - try it first.
50
+
51
+
Check out this [Fiddle](http://jsfiddle.net/jimschubert/85M4z/)
52
+
53
+
And this [Stack Overflow question](http://stackoverflow.com/questions/22395357/how-to-compare-two-arrays-are-equal-using-javascript)
54
+
55
+
**Some freeCodeCamp challenges:**
56
+
57
+
3.[Comparisons with the Logical And Operator](https://www.freecodecamp.com/challenges/comparisons-with-the-logical-and-operator)
@@ -17,7 +97,7 @@ And just for fun ... https://www.freecodecamp.com/challenges/sum-all-numbers-in-
17
97
18
98
And a custom DOM manipulation challenge :mortar_board:
19
99
20
-
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`).
100
+
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`).
21
101
22
102
2. Create a basic html file called inxed.html and use it to load the js file, confirm the console.log show the array. (This is for debugging and making sure everything is in order. Delete it later when you're done :))
23
103
@@ -29,4 +109,6 @@ And a custom DOM manipulation challenge :mortar_board:
29
109
30
110
6. Beautify your html page with css, add sources and alts to each of the images.
31
111
32
-
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_)
112
+
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_)
0 commit comments