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: JavaScript3/Week7/homework.md
+16-15Lines changed: 16 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,5 @@
1
1
# Homework Week 7
2
2
3
-
>[Here](/Week7/README.md) you find the readings you have to complete before the eighth lecture.
4
-
5
3
## Step 1: Map, filter, reduce, and =>
6
4
7
5
1. Say you would like to write a program that doubles the odd numbers in an array and throws away the even number.
@@ -32,28 +30,31 @@
32
30
1. Count the number of movies made between 1980-1989 (including both the years).
33
31
34
32
## Step 2: Continuing with the previous exercise
35
-
Note: Most of you have not completed the homework from last week, so this task will be difficult
36
33
37
34
- Add map, filter, reduce to your existing app to build an application that loads data from github, filters out based on certain value, map->reduces to a data object and render that object to the dom (using map again).
38
35
- For example you can try to use map, filter and reduce to show the most and the least forked repositories, watched repositories. And the total number of forks for all repo's. Also you can work with the data provided about the amount of commits or contributers.
39
36
- Add a readme to your repo explaining what your app does and how to use your app. Here's a [template](https://gist.github.com/jxson/1784669) and here you can see how to make [your readme awesome](https://gist.github.com/rrgayhart/91bba7bb39ea60136e5c).
40
37
41
-
## Step 2: **Some freeCodeCamp challenges:**
38
+
## Step 3: **Some freeCodeCamp challenges:**
42
39
43
40
1. [Comparisons with the Logical And Operator](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-and-operator/)
3. [Iterate over Arrays with map](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/use-the-map-method-to-extract-data-from-an-array)
2. [JS Event Loops](https://www.youtube.com/watch?v=8aGhZQkoFbQ) (26 mins, watch this one twice or until you understand it)
55
-
56
-
>Create a new repository "hyf-javascript3". Also create a new folder "week1" inside this repository.
57
-
Upload your homework files inside the week1 folder and write a description for this “commit”.
58
-
Your hyf-javascript3/week1 should now contain the files of your homework.
59
-
Place the link to your repository folder in Trello.
46
+
## Step 4: Hand in Homework:
47
+
Go over your homework one last time:
48
+
49
+
- Does every file run without errors and with the correct results?
50
+
- Have you used `const` and `let` and avoided `var`?
51
+
- Do the variable, function and argument names you created follow the [Naming Conventions](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md)?
52
+
- Is your code well-formatted (see [Code Formatting](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md))?
If you can answer yes to the above questions then you are ready to hand in the homework:<br/>
55
+
- Find the hyf-homework git repo (that you have forked from [here](https://github.com/HackYourFuture-CPH/hyf-homework)) the link will be https://github.com/YOUR-ACCOUNT/hyf-homework
56
+
- Add your homework files in the Javascript/javascript3/week7 folder
57
+
- To finish the homework post the link for your repo and the rendered index.html on your classes slack channel
Copy file name to clipboardExpand all lines: JavaScript3/Week8/homework.md
+30-24Lines changed: 30 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,5 @@
1
1
# Homework Week 8
2
2
3
-
>[Here](https://github.com/HackYourFuture-CPH/JavaScript/blob/master/JavaScript3/Week8/README.md) you find the readings you have to complete before the ninth lecture.
4
-
5
3
## Step 1: Closure
6
4
7
5
>Revise before attempting: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures
@@ -47,35 +45,29 @@ We have an array with the numbers from 1 to 1000. Now we are interested in all n
47
45
console.log("Amount of numbers divisible by 21: ",divisbleBy21.length);
48
46
```
49
47
50
-
Your task is now, to implement a closure (a function factory), that generates functions which allow us to determine all numbers that are divisible by "WHAT EVER NUMBER".
51
-
52
-
>Hint: Use `map`, `filter` and `reduce`. Think about the sizes of your arrays and then choose whether you need `map`, `filter` or `reduce`
48
+
## Part 1
49
+
Your task is now, to implement a closure (a function factory), that generates functions which allow us to determine if a number is divisible by some other number. The return of the inner function will be a boolean.
53
50
51
+
So just like with our adder function we want to use it like this:
54
52
```js
55
-
let arr = [];
56
-
for( let i=1; i<=1000;i++){
57
-
arr.push(i);
58
-
}
59
-
console.log(arr);
60
-
61
-
// here please start your solution
62
-
// using closures, functions and (map,filter,reduce)
console.log(divisibilityCheckerFive(2)) // logs out false
69
55
```
70
56
71
-
Once you have the factory function above working well for 3, 10 and 21, create an array which uses this factory above to calculate the number of item in `arr` above which are divisible by numbers between 1-30 i.e. your array will contain 30 items and looks something like this:
72
-
57
+
## Part 2
58
+
Create an array where the first element in that array is equal to the number of numbers (in ```arr```) that are divisible 1. The second element should be equal to the number of numbers that are divisible by 2. And so on. Use the divisibilityChecker function you created in part 1.
// 1000 items are divisible by 1, 500 by 2 and son on...
77
64
```
78
65
66
+
> Hint: Use `map`, `filter` and `reduce`. Think about the sizes of your arrays and then choose whether you need `map`, `filter` or `reduce`. A good old `forEach` would also be fine.
## Step 2: Continuing with data loading, processing and rendering
80
72
81
73
>Revise before attempting: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
@@ -88,8 +80,22 @@ Using [the movies json file from the previous exercise](https://gist.githubuserc
88
80
1. Add 4 radio buttons for each tag + All tag (All, Good, Average, Bad) and filter the movies based on the tag selected.
89
81
1. Display only the movies in the list which match the two filter criterion above.
90
82
1. Display the average rating of the movies being filtered and displayed.
83
+
1.**Extra task:** For every movie you render add a button somewhere that says "Get poster".
84
+
When clicking this button it gets the poster for the movie using this api: http://www.omdbapi.com/. You first need to get an api key! See if you can figure out how it works by yourself. If not you are always welcome to ask :)
85
+
86
+
You could also add the actors from the movie. And if you wanna go really crazy add their portrait from this api: https://www.themoviedb.org
87
+
88
+
Remember to use the promises, map, filter and reduce!
89
+
90
+
## Step 3: Hand in Homework:
91
+
Go over your homework one last time:
91
92
92
-
Remember to use the following to help with your code:
93
+
- Does every file run without errors and with the correct results?
94
+
- Have you used `const` and `let` and avoided `var`?
95
+
- Do the variable, function and argument names you created follow the [Naming Conventions](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md)?
96
+
- Is your code well-formatted (see [Code Formatting](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md))?
93
97
94
-
1. Promises to simplify data loading, [covered in this lecture](./classwork/new-ajax.js).
95
-
1. Filter, map, reduce functions + Arrow functions, [covered in last lecture](../Week7/classwork/demonstration.js).
98
+
If you can answer yes to the above questions then you are ready to hand in the homework:
99
+
* Find the hyf-homework git repo (that you have forked from [here](https://github.com/HackYourFuture-CPH/hyf-homework)) the link will be https://github.com/YOUR-ACCOUNT/hyf-homework
100
+
* Add your homework files in the Javascript/javascript3/week8 folder
101
+
* To finish the homework post the link for your repo and the rendered index.html on your classes slack channel
-[Why closures are helpful with async code](http://stackoverflow.com/questions/13343340/calling-an-asynchronous-function-within-a-for-loop-in-javascript)
0 commit comments