Skip to content

Commit 8a2f0f0

Browse files
committed
added homework week 9
1 parent dd55c3f commit 8a2f0f0

1 file changed

Lines changed: 20 additions & 30 deletions

File tree

‎Week9/MAKEME.md‎

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Homework Week 9
22

3+
### Step 0: Read
4+
35
>Read:
46
- JavaScript : [Closures](http://conceptf1.blogspot.nl/2013/11/javascript-closures.html)
57
- Everything you wanted to know about [JavaScript scope](https://toddmotto.com/everything-you-wanted-to-know-about-javascript-scope/)
@@ -9,24 +11,23 @@
911
- More about [closures](https://www.reddit.com/r/learnjavascript/comments/1v6n8p/closure_explain_likei_am_in_high_school/?st=ixsp0mbe&sh=5526d150)
1012
- A VERY popular [StackOverflow article](http://stackoverflow.com/questions/111102/how-do-javascript-closures-work)
1113

14+
### Step 1: Scope and Closures
1215

13-
14-
> Make:
15-
1. Let's continue to learn a little more about scope and Closures.
16+
> Let's continue to learn a little more about scope and Closures.
1617
1718

1819
2. What will be the output of the following code - and more importantly - WHY?
1920

2021
```js
21-
for (var i = 0; i < 3; i++) {
22+
for (let i = 0; i < 3; i++) {
2223
setTimeout(function() { alert(i); }, 1000 + i);
2324
}
2425
```
2526

2627

2728
3. Write a function that would allow you to do this:
2829
```js
29-
var addSix = createBase(6);
30+
let addSix = createBase(6);
3031
addSix(10); // returns 16
3132
addSix(21); // returns 27
3233
```
@@ -42,8 +43,8 @@ Don't cheat - but if you get stuck ... http://stackoverflow.com/questions/750486
4243

4344
<script type="text/javascript">
4445
45-
var prizes = ['A Unicorn!', 'A Hug!', 'Fresh Laundry!'];
46-
for (var btnNum = 0; btnNum < prizes.length; btnNum++) {
46+
let prizes = ['A Unicorn!', 'A Hug!', 'Fresh Laundry!'];
47+
for (let btnNum = 0; btnNum < prizes.length; btnNum++) {
4748
// for each of our buttons, when the user clicks it...
4849
document.getElementById('btn-' + btnNum).onclick = function() {
4950
// tell her what she's won!
@@ -53,57 +54,46 @@ Don't cheat - but if you get stuck ... http://stackoverflow.com/questions/750486
5354
</script>
5455
```
5556

56-
Rewrite to Async:
57+
5. Rewrite the code below to Async:
5758

5859
```js
5960
1.
6061

61-
var sum = calculateSum(2, 6);
62+
let sum = calculateSum(2, 6);
6263
console.log(sum);
6364

6465
2.
6566

66-
var results = $.getJSON('http://myapi.com');
67+
let results = $.getJSON('http://myapi.com');
6768
showResults(results);
6869

6970
3.
7071

71-
var sum = calculateSum(2, 6);
72+
let sum = calculateSum(2, 6);
7273
if (sum > 8) {
7374
console.log('larger than 8');
7475
}
7576

7677
4.
7778

78-
var data = $.getJSON('http://myapi.com');
79+
let data = $.getJSON('http://myapi.com');
7980
data = data.map(function (x) { return x * 8; });
8081

8182
writeDataToFile(data);
8283
```
8384

8485

85-
4. You will need to create an HTML document out of the below snippet to run the below code. A hint - the code is syntactically correct but doesn't do what you would expect. Can you see why and fix it?
86+
### Step 2: Feedback
8687

87-
TODO !!!
88+
- Create at least 2 issues (bug / feature / code improvement) on another teams github repository. Do this in pairs.
89+
- 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)
8890

89-
Choose two "GET" API endpoints from http://reqres.in
90-
Use $.getJSON to load data from those two endpoints
91-
Display the data on your web page.
92-
It should not matter which endpoint is loaded first, the data should always look the same (you can add "?delay=" after the endpoint to simulate a delay).
91+
## Step 3: Pair programming homework
9392

94-
• Create at least 1 issue (bug / feature / code improvement) on another students github repository. Do this in pairs.
95-
• solve the issue proposed by another student in your github repo. More info [here](https://hackyourfuture.slack.com/files/michahell/F31BX1XT6/Merging_a_local_branch_into_master)
93+
You will complete the TicTacToe game we started building in class. The code we build in class is available here: *(will be here by the end of the day)*.
94+
One of your teammates should fork the repo. Work in this repository *together* so you can see who wrote which code. Make a Pull Request to hand in this part of the homework.
9695

97-
98-
## Optional homework
99-
```
100-
TicTacToe game
101-
102-
https://github.com/HackYourFuture/TicTacToeTDD
103-
https://github.com/HackYourFuture/OOP-Student-and-Teacher
104-
105-
rewatch the Hangouts session here: https://www.youtube.com/watch?v=oc9ogCJz9rYs
106-
```
96+
<!-- rewatch the Hangouts session here: https://www.youtube.com/watch?v=oc9ogCJz9rYs -->
10797

10898
>Upload your homework in your "hyf-javascript3" Github repository. Make sure to create a new folder "week3" first.
10999
Upload your homework files inside the week3 folder and write a description for this “commit”.

0 commit comments

Comments
 (0)