Topics discussed this week:
• Object Oriented Programming and ES6 Classes
• The this keyword
• call, apply, bind
Deadline Monday
- Fix Requested Changes (if any) on the Pull Request.
Deadline Thursday
Read the fundamental pages on:
The homework for week 3 will build on the work you did in week 2. You will create a new branch based on the week2
branch.
-
Make sure that you committed all changes in the week 2 version of your homework.
-
Create a new
week3
branch:git checkout -b week3
This week you will work with all JavaScript files in the src
folder. The assignment consists of two parts:
- Replace
XMLHttpRequest
with thefetch
API. - Refactor all
.then()
and.catch()
methods withasync
/await
andtry...catch
. - Make your app ARIA-compliant (see below).
- Refactor your application to use ES6 classes.
Replace XMLHttpRequest
in the fetchJSON
function with fetch
. Because fetch
returns a promise out of the box there is no need create a promise yourself with new Promise(...)
.
fetch
does not throw an error for HTTP errors. Review the documentation forresponse.ok
for a clue how detect HTTP errors.
Instructions:
-
Refactor all
.then()
and.catch()
methods withasync
/await
andtry...catch
. -
Make sure that your error handling code still works. See the week2 MAKEME on how to force an error response from GitHub.
Deadline Saturday
This final assignment requires you to go the extra mile and master Object Oriented Programming and ES6 classes.
The files to be modified are in the homework-classes folder.
In this assignment you need to redistribute and adapt the code from index.js
to the files App.js
, Repository.js
and Contributor.js
. You do not need to modify Util.js
.
File | Description |
---|---|
index.html |
The application's HTML file. |
App.js |
The App class contains the start-up code and manages the overall orchestration of the app. |
Repository.js |
The Repository class holds code and data for a single repository. |
Contributor.js |
The Contributor class holds code and data for a single contributor. |
Util.js |
The Util class contains static helper methods for use in the other classes. |
The App.js
, Repository.js
and Contributor.js
files each contain skeleton code that you can use to migrate portions of your code from index.js
to.
Read:
- HYF fundamental: ES6 Classes
- More on ES6 classes: ES6 Classes in Depth
Please review the material from the HTML/CSS module: Get familiar with Accessible Rich Internet Applications (ARIA).
For the GitHub application ARIA-compliance means that the Contributors list should either be a native HTML list (i.e. using ul
and li
elements) or otherwise marked with an appropriate ARIA role. Furthermore, a user should be able to navigate through all interactive elements using the keyboard (e.g., using the Tab key). Pressing Enter on such an element should be equivalent to clicking the mouse.
If necessary, review the instructions how to Hand in homework using GitHub pull request.
To test whether your code will be accepted when you submit your homework as a pull request you need to ensure that it does not contain ESLint errors. Open a terminal window in VSCode and type the following command:
npm test
If any errors or warnings are reported by this command you need to fix them before submitting a pull request.
In addition, check for the following:
- Have you removed all commented out code (should never be present in a PR)?
- Do the variable, function and argument names you created follow the Naming Conventions?
- Is your code well-formatted (see Code Formatting)?
If the answer is 'yes' to the preceding questions you are ready to follow these instructions:
-
Push your
week3
branch to GitHub:git push -u origin week3
-
Create a pull request for your
week3
branch.
Deadline Sunday morning
Go trough the reading material in the README.md of the Node repository to prepare for your next class.
If you haven't already join our clan: "Hack Your Future" in codewars
Solve the following problems:
Hints
- Hint for Q1: split your code into two parts, one part for the case that one of the two strings has an extra letter at the start or the end but is otherwise identical & one part for the case that the strings are the same length but one character is different in one of the strings
- Also for Q1 this function on strings might be useful: JavaScript String slice() method
- Also potentially useful: JavaScript String charAt() Method
- Hint for Q2 Also there are no sample tests, you need to use submit
Remember the person with the most kata points gets a prize from Gijs (and you can do exercises on this website without us assigning them - anything kyu 7 or kyu 8 you can try to do - kyu 6 or lower is probably too hard) -->
-MORE BONUS 💥