|
1 | | -# Homework Week 3 |
| 1 | +# Homework Week 2 |
2 | 2 |
|
3 | 3 | ``` |
4 | 4 | Topics discussed this week: |
5 | | -• (re)writing data structures (in JSON) |
6 | | -• Async VS Sync |
7 | | -• Code flow (order of execution) |
| 5 | +• Async vs Sync |
| 6 | +• Event Loop (order of execution) |
| 7 | +• Promises |
8 | 8 | ``` |
9 | 9 |
|
10 | 10 | ## Step 1: Read |
11 | 11 |
|
12 | | -- If you need to refresh your memory on es6 classes: [es6-classes-in-depth](https://ponyfoo.com/articles/es6-classes-in-depth) |
13 | | -- Also read this article on scopes & closures: [explaining-javascript-scope-and-closures](https://robertnyman.com/2008/10/09/explaining-javascript-scope-and-closures/) |
| 12 | +- Read this article on scopes & closures: [explaining-javascript-scope-and-closures](https://robertnyman.com/2008/10/09/explaining-javascript-scope-and-closures/) |
14 | 13 |
|
15 | | -## Step 2: Feedback |
16 | | - |
17 | | -- Create at least 2 issues (bug / feature / code improvement) on another teams github repository. Do this in pairs. |
18 | | -- Solve the issue proposed by another students in your github repo. More info [here](https://hackyourfuture.slack.com/files/michahell/F31BX1XT6/Merging_a_local_branch_into_master) |
| 14 | +- If you are still not completely clear on promises, here are some additional nice resources :ring: |
19 | 15 |
|
20 | | -## Step 3: Pair programming promises challenge |
| 16 | + - [Googles post about Promises](https://developers.google.com/web/fundamentals/getting-started/primers/promises) |
| 17 | + - [A nice article from David Walsh](https://davidwalsh.name/promises) |
| 18 | + - [A real life example](https://github.com/mdn/js-examples/blob/master/promises-test/index.html) |
| 19 | + - [stackoverflow](http://stackoverflow.com/questions/13343340/calling-an-asynchronous-function-within-a-for-loop-in-javascript) |
| 20 | + - YouTube: [promises](https://www.youtube.com/watch?v=WBupia9oidU) |
21 | 21 |
|
22 | | -This week you will work in a team! |
23 | 22 |
|
24 | | -So please: |
| 23 | +## Step 2: Feedback |
25 | 24 |
|
26 | | -- (one of your team mates should) Fork this repository: https://github.com/HackYourFuture/PromisessObjectsAndStringRendering |
27 | | -- make sure you are all collaborators on the same repository |
28 | | -- Follow the instructions in the REAME.md of the above repository |
29 | | -- To hand in your homework you make a PR to the existing repository |
| 25 | +- Create at least 2 issues (bug / feature / code improvement) on another student's GitHub repository. |
| 26 | +- Solve the issue(s) proposed by another students in your GitHub repository. More info [here](https://hackyourfuture.slack.com/files/michahell/F31BX1XT6/Merging_a_local_branch_into_master). |
30 | 27 |
|
31 | | -## Step 4: Async challenge |
| 28 | +## Step 3: Promises |
32 | 29 |
|
33 | 30 | _Deadline Saturday_ |
34 | 31 |
|
35 | | -1. Rewrite the code below to Async: |
36 | | - |
37 | | -```js |
38 | | -1. |
39 | | - |
40 | | -let sum = calculateSum(2, 6); |
41 | | -console.log(sum); |
42 | | - |
43 | | -2. |
44 | | - |
45 | | -let results = $.getJSON('http://myapi.com'); |
46 | | -showResults(results); |
| 32 | +The assignment for this week is: |
47 | 33 |
|
48 | | -3. |
49 | | - |
50 | | -let sum = calculateSum(2, 6); |
51 | | -if (sum > 8) { |
52 | | - console.log('larger than 8'); |
53 | | -} |
54 | | - |
55 | | -4. |
56 | | - |
57 | | -let data = $.getJSON('http://myapi.com'); |
58 | | -data = data.map(function (x) { return x * 8; }); |
59 | | - |
60 | | -writeDataToFile(data); |
61 | | -``` |
| 34 | +- Complete your GitHub app code as needed to meet the requirements from the assignment of week 1. |
| 35 | +- Replace all asynchronous callbacks (e.g. as used with XMLHttpRequest) by ES6 promises. |
| 36 | +- Beautify your app's styling. |
62 | 37 |
|
63 | 38 | ## Step 5: Read before next lecture |
64 | 39 |
|
65 | | -_Deadline Sunday morning_ |
66 | | - |
67 | | -Go trough the reading material in the [README.md](https://github.com/HackYourFuture/Node.js) to prepare for your next class |
| 40 | +Go trough the reading material in the [README.md](/Week3/README.md) to prepare for your next class. |
68 | 41 |
|
69 | | -> To hand in your homework, make a pull request to the original repository you forked from. Remember, our master branches are protected, you cannot push to a directly cloned repository you first have to make a fork to your own Github. |
0 commit comments