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: Week1/MAKEME.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -136,7 +136,7 @@ The returned JSON data contains some basic information about each repository, su
136
136
137
137
Do the following to fulfill this week's requirements:
138
138
139
-
1. Modify **`imdex.js`**: Modify whatever you need in order to successfully make an API call to the HackYourFuture GitHub account and display the results inside the DOM. It is not likely that you will need to modify `fetchJSON()` and `createAndAppend()`.
139
+
1. Modify **`index.js`**: Modify whatever you need in order to successfully make an API call to the HackYourFuture GitHub account and display the results inside the DOM. It is not likely that you will need to modify `fetchJSON()` and `createAndAppend()`.
140
140
141
141
2. Add your own CSS styling inside **`style.css`**. Avoid using JavaScript for styling unless there is a genuine need. **You are not allowed to use a CSS library such as Bootstrap.**
Copy file name to clipboardExpand all lines: Week3/README.md
+33-5Lines changed: 33 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ However, in the evolution of programming languages programmers started to think
32
32
33
33
In this week you'll be exposed to one such programming style that evolved: `object oriented programming` (or OOP for short). OOP is a fundamentally different way of writing software: instead of breaking up a problem in variables and functions that operate on those variables, we break problems up into "entities" that interact with each other.
34
34
35
-
> Just to make sure you completely get the idea here: OOP is about a different way of thinking about how to write software. The concepts of variables, functions, promises, API (calls) and error handling all still apply. It's just that the way code is organised is differently. Instead of creating long procedures, we create objects that interact with each other.
35
+
> Just to make sure you completely get the idea here: OOP is about a different way of thinking about how to write software. The concepts of variables, functions, promises, API (calls) and error handling all still apply. It's just that the way code is organised is different. Instead of creating long procedures, we create objects that interact with each other.
36
36
37
37
For further study, check the following:
38
38
@@ -178,7 +178,7 @@ const noer = new Person('Noer', 27);
178
178
179
179
### Classes
180
180
181
-
As you've learned in the previous section, in JavaScript we can do this using `factory/constructor function`.
181
+
As you've learned in the previous section, in JavaScript we can do this using `factory or constructor functions`.
182
182
183
183
Since ES6 we can make use of the `class` keyword, which is a way to create constructor objects as well. It's essentially the same thing as a constructor function, only written in a clearer and more straightforward way.
Then we learned about how Promises are an improved on callbacks, by providing the developer with a more readable syntax that avoids **callback hell**. We can call them callbacks version 2.0.
201
+
Then we learned about how Promises are an improvement upon callbacks, by providing the developer with a more readable syntax that avoids **callback hell**. We can call them callbacks version 2.0. Here's the basic structure again:
202
202
203
203
```js
204
204
newPromise(reject, resolve).then(...);
205
205
```
206
206
207
-
And now we've arrived at the latest upgrade of the callback mechanism: `async/await`.
207
+
And now we've arrived at the latest upgrade of the callback mechanism: `async/await`. This construct is part of **ECMAScript 6** and its main benefit is to make using callbacks even more readable. Here's how it might look in action:
This new construct makes use of the Promise object, in the same way that Promises make use of callback functions.
218
+
219
+
How do we use it? We put the keyword `async` in front of the function declaration that will contain asynchronous code. Then in every line that returns the Promise we put the keyword `await` in front.
220
+
221
+
For more research, check the following resources:
222
+
212
223
-[The Evolution of Callbacks, Promises & Async/Await](https://www.youtube.com/watch?v=gB-OmN1egV8)
As you might have noticed, the Async/Await doesn't give us a way to do error handling like it does in the Promise object.
218
229
219
-
In the Promise object we have access to the `catch()` function,
230
+
In the Promise object we are given access to the `catch()` function, a function whose sole job it is to "catch errors". "Catching errors" is a phrase developers use to indicate various things:
231
+
232
+
1. that a line of code has caused an error
233
+
2. that the program has shutdown to prevent any other errors from happening
234
+
3. that the application gives feedback to the developer and/or user
235
+
236
+
In the Promise object, we can use the function `catch` to take care of errors. It takes in a callback, which automatically receives an error object. Here's an example:
237
+
238
+
```js
239
+
Promise.catch(function(error) {
240
+
console.log(error);
241
+
});
242
+
```
243
+
244
+
With the Async/Await construction, we don't get that. So instead we have to use some other solution: the `try... catch` block. It's also an addition to the language, given to us by **ECMAScript 6**.
0 commit comments