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

Skip to content

Commit 438b6a9

Browse files
authored
Merge branch 'master' into master
2 parents 987a0e7 + b1d3c3e commit 438b6a9

File tree

5 files changed

+85
-45
lines changed

5 files changed

+85
-45
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Here you can find course content and homework for the JavaScript 1,2 and 3 modul
1313
|2.|• Advanced data types [Objects] <br>• Conditions <br>• Statements vs Expressions<br> • Loops (for/while)<br>• Functions <br>• Naming conventions|[Reading Week 2](https://github.com/HackYourFuture/JavaScript/tree/master/Week2/README.md)|[Homework Week 2](https://github.com/HackYourFuture/JavaScript/tree/master/Week2/MAKEME.md)|[Review](https://github.com/HackYourFuture/JavaScript/blob/master/Week2/REVIEW.md)|
1414
|3.|[CLI](https://github.com/HackYourFuture/CommandLine) session with Unmesh :balloon: <br>• Closures <br>• Scope <br>• Array Manipulations <br>• Basic DOM manipulations [img src, innerHTML]<br>• Code commenting|[Reading Week 3](https://github.com/HackYourFuture/JavaScript/tree/master/Week3)|[Homework Week 3](https://github.com/HackYourFuture/JavaScript/tree/master/Week3/MAKEME.md)|[Review](https://github.com/HackYourFuture/JavaScript/blob/master/Week3/REVIEW.md)|
1515
|4.|• JSON<br>• Code debugging using the browser<br>• Functions + JSON/Arrays<br>• Code flow (order of execution) <br>• (capturing user input) <br>• Structuring code files|[Reading Week 4](https://github.com/HackYourFuture/JavaScript/tree/master/Week4)|[JS](https://github.com/HackYourFuture/JavaScript/tree/master/Week4/MAKEME.md) + [Git Homework Week 4](https://github.com/HackYourFuture/Git/blob/master/Lecture-1.md)|Review|
16-
|5.|• First Git Session with Unmesh :smiling_imp:<br>• Events<br>• Callbacks <br>• XHTTP Requests <br>• API calls|[Reading Week 5](https://github.com/HackYourFuture/JavaScript/tree/master/Week5)|[Homework Week 5](https://github.com/HackYourFuture/JavaScript/tree/master/Week5/MAKEME.md)|Review|
16+
|5.|• First Git Session with Unmesh :smiling_imp:<br>• Events<br>• Callbacks <br>• XHTTP Requests <br>• API calls|[Reading Week 5](https://github.com/HackYourFuture/JavaScript/tree/master/Week5)|[Homework Week 5](https://github.com/HackYourFuture/JavaScript/tree/master/Week5/MAKEME.md)|[Review](https://github.com/HackYourFuture/JavaScript/blob/master/Week5/REVIEW.MD)|
1717
|6.|• Second Git Session :see_no_evil:<br> • Async VS Sync<br>• Polling<br>• Structure for a basic SPA<br> TEST :boom:|[Reading Week 6](https://github.com/HackYourFuture/JavaScript/tree/master/Week6)|[Homework Week 6](https://github.com/HackYourFuture/JavaScript/tree/master/Week6/MAKEME.md)|Review|
1818
|7.|• Third Git Session (Git Workflow :muscle:)<br>• Map, reduce, filter <br> • Arrow functions|[Reading Week 7](https://github.com/HackYourFuture/JavaScript/tree/master/Week7)|[Homework Week 7](https://github.com/HackYourFuture/JavaScript/tree/master/Week7/MAKEME.md)|Review|
1919
|8.|• (re)writing data structures (in JSON)<br> • Closures <br>• Promises <br>|[Reading Week 8](https://github.com/HackYourFuture/JavaScript/tree/master/Week8/README.md)|[Homework Week 8](https://github.com/HackYourFuture/JavaScript/tree/master/Week8/MAKEME.md)|Review|

Week0/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ To test that it was installed and running properly, go to your terminal and run
1919
Please watch the following parts of the course, [Programming Foundations Fundamentals](https://www.lynda.com/Programming-Foundations-tutorials/Welcome/83603/90426-4.html) on Lynda.com (if you don't have access to Lynda yet ask Gijs):
2020

2121
Only watch the below chapters:
22+
2223
0. Introduction
2324
1. Programming Basics
2425
2. Core Programming Syntax

Week5/REVIEW.MD

Lines changed: 0 additions & 14 deletions
This file was deleted.

Week5/REVIEW.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# REVIEW week 5
2+
3+
```
4+
this review covers:
5+
• Git Session
6+
• Events
7+
• Callbacks
8+
• XHTTP Requests
9+
• API calls
10+
```
11+
12+
## Callbacks
13+
14+
- JavaScript callback functions tutorial: https://www.youtube.com/watch?v=pTbSfCT42_M&index=17&list=WL
15+
16+
## XMLHttpRequest
17+
**XMLHttpRequest** is an object to interact with servers. You can retrieve data from a URL without having to do a full page refresh. XMLHttpRequest is used heavily in Ajax programming - [MDN](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest).
18+
19+
So what is Ajax?
20+
**Ajax** is a method of exchanging data with a server, and updating parts of a web page without reloading the entire page.
21+
22+
Let's dive into the code:
23+
24+
First, we need to make an instance from 'XMLHttpRequest' object.
25+
```js
26+
var http = new XMLHttpRequest();
27+
```
28+
When we are doing a request it goes through 5 states:
29+
* 0 : request is not initialized.
30+
* 1 : request has been set up.
31+
* 2 : request has been sent.
32+
* 3 : request is in process.
33+
* 4 : request is complete.
34+
35+
In the code below we are checking if the request is complete or not, and we check the status == 200 just to make sure that we do not get a 404 error - Read more about it here: [HTTP Status Code](https://httpstatuses.com).
36+
```js
37+
http.onreadystatechange = function() {
38+
if ( http.readyState == 4 && http.status == 200) {
39+
console.log('Response from the server: ' + http.response);
40+
}
41+
}
42+
```
43+
There are methods to deal with a server like (GET, POST, UPDATE, DELETE…)
44+
45+
* GET: retrieve data from server.
46+
* POST: send data to server.
47+
* UPDATE: update data on the server.
48+
* DELETE: delete date from the server.
49+
50+
To initialize a request we use [open](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/open) method. The syntax is:
51+
```js
52+
XMLHttpRequest.open(method, url, async, user, password);
53+
```
54+
The parameters _method_ and _url_ are mandatory, _user_ and _password_ are optional. True is a default value for _async_.
55+
56+
```js
57+
http.open("GET", URL, true/false);
58+
```
59+
At the end we have to send our request to the server through [send](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/send) method. In our situation we are retrieving a data from the server, so we do not have to pass a parameter to the send request.
60+
61+
```js
62+
http.send();
63+
```

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: https://github.com/HackYourFuture/TicTacToeTDD.
94+
One of your teammates should fork the above 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)