- Practice the concepts
- JavaScript exercises
- Code along
- PROJECT: Hack Your Repo II
Let's start this week off with some interactive exercises! Visit the following link to get started:
No exercises this week
In the following "code along" you'll be building a complete Weather App that makes use of the Darksky API.
Enjoy!
The assignment this week is to enhance your application to look similar to the following:
As you can see, it looks different from the one from last week. This week we'll be rewriting most of our code to now show information for a single repository and also list its contributors (instead of the details for all repositories). A user should be able to search for all repositories in the account and select the one they want more information on.
The enhanced application should fulfill the following requirements:
- The list of repositories in the
selectelement should be sorted (case-insensitive) on repository name. - At start-up your application should display information about the first repository as displayed in the
selectelement. - When the user changes the selection, the information in the web page should be refreshed for the newly selected repository.
- You should be able to click on the repository name of the selected repository to open a new browser tab with the GitHub page for that repository.
- You should be able to click on a contributor to open a new browser tab with the GitHub page for that contributor.
- Your UI should be responsive. Try it with Chrome Developer Tools in the browser, using a mobile phone format and a tablet format, portrait and landscape.
- The
XMLHttpRequestin thefetchJSONfunction should be replaced withfetch. Hint: Becausefetchreturns a promise out of the box there is no need create a Promise yourself withnew Promise(...).
Hints:
-
The
index.htmlfile can be divided into several components:- An HTML
selectelement from which the user can select a HYF repository. Thisselectelement must be populated withoptionelements, one for each HYF repository. - A left-hand column that displays basic information about the selected repository.
- A right-hand column that displays a list of contributors to the repository.
A suggested HTML structure could be:
<body> <div id="root"> <header class="...">...</header> <main class="main-container"> <section class="repo-container">...</section> <section class="contributors-container">...</section> </main> </div> </body>
- An HTML
-
Add one
optionelement per repository to theselectelement, where eachoptionelement has the array index of the repository as itsvalueattribute and the name of the repository as its text content:<select> <option value="0">alumni</option> <option value="1">angular</option> <!-- etc --> </select>
-
To sort the list repositories use
.sort()and.localeCompare().
Good luck!
After you've finished your todo list it's time to show us what you got! The homework that needs to be submitted is the following:
- PROJECT: HackYourRepo II
Upload your homework to your forked JavaScript3 repository in GitHub. Make a pull request to your teacher's repository.
Forgotten how to upload your homework? Go through the guide to learn how to do this again.
Deadline Saturday 23.59 CET
