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

Skip to content

Commit 43ab4f0

Browse files
authored
Merge pull request HackYourFuture#414 from HackYourFuture/module-revision
Module revision
2 parents b346201 + cb76bea commit 43ab4f0

35 files changed

+694
-730
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"remarcmij",
1313
"tabindex",
1414
"whiteframe"
15-
]
15+
],
16+
"deno.enable": false
1617
}

README.md

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,47 @@ Welcome to JavaScript3! Congratulations on making it this far. You're well on yo
99

1010
A big part of being a programmer means moving data from one place to another. It also means working with other people's software. In this module you'll be learning about one of the core things of what makes a web developer: working with APIs!
1111

12-
On top of that you'll also learn how to think differently about how you write your programs. Like in any field, once you've mastered a particular way of doing things you start thinking about how it could be done differently. In programming we call these `paradigms` and in this module you'll learn one such paradigm: Object-Oriented Programming!
12+
On top of that you'll also learn how to think differently about _how_ you write your programs. Like in any field, once you've mastered a particular way of doing things you start thinking about how it could be done in a smarter, different way. In programming we call these `paradigms` and in this module you'll learn one such paradigm: Object-Oriented Programming!
1313

1414
## Learning goals
1515

1616
In order to successfully complete this module you will need to master the following:
1717

18-
- Learn what an API is
19-
- Catch up on the history of JavaScript
20-
- Understand how to write more readable asynchronous JavaScript
21-
- Connect with different public APIs
22-
- Build a Single Page Application (SPA)
18+
- Learn what an `Application Programming Interface` (API) is
19+
- Catch up on the `history of JavaScript`
20+
- Understand how to write more readable `asynchronous JavaScript`
21+
- Connect with different `public APIs`
22+
- Build a `Single Page Application` (SPA)
2323
- Work with pre-existing code
24-
- Learn about Object-Oriented Programming
24+
- Learn about `Object-Oriented Programming`
2525

2626
## How to use this repository
2727

2828
This repository consists of 3 essential parts:
2929

30-
1. `Reading materials`: this document contains all the required theory you need to know _**while**_ you're coding. It's meant as both study material and as a reference to understand what you're doing.
31-
2. `Homework`: this document contains the instructions for each week's homework.
32-
3. `Lesson Plans`: this part is meant for teachers as a reference. However, as a student don't be shy to take a look at it as well!
30+
1. `README`: this document contains all the required theory you need to understand **before** class. It's also meant as a reference to understand what you're doing while you're coding.
31+
2. `MAKEME`: this document contains the instructions for each week's homework.
32+
3. `LESSONPLAN`: this document is meant for teachers as a reference. However, as a student don't be shy to take a look at it as well!
3333

34-
After your first class you should start off with checking the `reading materials` for that week. At the beginning that would be the [Week 1 Reading](/Week1/README.md). Study all the concepts and try to get the gist of everything. After, you can get started with the `homework` for that week.
34+
**Before** the first class of the module you should start off with the [Week 1 Reading](/Week1/README.md). Study all the concepts and try to get the gist of everything. After your first class, you can get started with the [Week 1 Homework](/Week1/MAKEME.md).
3535

3636
If you have any questions or if something is not entirely clear ¯\\\_(ツ)\_/¯, please ask/comment on Slack!
3737

3838
## Before you start
3939

40-
In the following weeks we will be using a `styleguide` to help you write _"clean code"_. What is a styleguide? Simply put, it's a set of design standards put in one collection. Companies create and use them to define their public identity (their "brand"). Watch the following to get a better idea:
40+
### Setup Style Guide
4141

42-
- [Creating Your Company's Style Guide](https://www.youtube.com/watch?v=gv_wrrY70E0)
42+
In the following weeks we will be using a front-end `style guide` to help you write _"clean code"_. What is a style guide? Simply put, it's a set of coding standards put into one collection.
4343

44-
A styleguide is made by designers. In the case of website design, this styleguide is then handed over to developers to use when styling the frontend.
44+
- [Front-end Style Guides](https://fronteers.nl/congres/2015/sessions/front-end-style-guides-anna-debenham)
4545

46-
The styleguide we'll be using is the one from Airbnb:
46+
The style guide we'll be using is the one from Airbnb:
4747

4848
- [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript)
4949

5050
While you do not need to read this guide in detail, it is recommended that you look at sections 1-8, 12-13, 15-21 and 23.
5151

52-
The required packages you need to install in order to write code according to the styleguide are the following:
52+
The required packages you need to install before you write code according to the style guide are the following:
5353

5454
```json
5555
"eslint"
@@ -60,13 +60,26 @@ The required packages you need to install in order to write code according to th
6060
"prettier"
6161
```
6262

63-
They are already in this repository's `package.json` so all you have to do now to prepare is to execute the following command in your command line:
63+
They are already in this repository's `package.json` so all you have to do now to prepare is to execute the following command at the root of this module directory:
6464

6565
```md
6666
npm install
6767
```
6868

69-
With this out of the way we can get started!
69+
### Forking the right repository
70+
71+
Before you start with the homework, make sure you've made a fork of the right repository: [HackYourHomework/JavaScript3](https://www.github.com/hackyourhomework/javascript3)). Once you've cloned it to your computer you can proceed by making GIT branches for each week. Start at the `master` branch and execute the following (note that they're 3 different commands):
72+
73+
```bash
74+
foo@bar:~$ git branch week1-YOURNAME
75+
foo@bar:~$ git branch week2-YOURNAME
76+
foo@bar:~$ git branch week3-YOURNAME
77+
```
78+
79+
Then execute `git checkout week1-YOURNAME` and you can get started!
80+
81+
If you have any questions or if something is not entirely clear ¯\_(ツ)\_/¯, please ask/comment on Slack!
82+
7083

7184
## Planning
7285

Week1/MAKEME.md

Lines changed: 58 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -15,160 +15,110 @@ This week's concepts can be challenging, therefore let's get an easy introductio
1515

1616
## **2. JavaScript exercises**
1717

18-
> Inside of your `JavaScript3` fork and inside of the `Week1` folder, create a folder called `homework`. Inside of that folder, create a folder called `js-exercises`. For all the following exercises create a new `.js` file in that folder (3 files in total). Make sure the name of each file reflects its content: for example, the filename for exercise one could be placeKitten.js.
18+
> Inside of your `JavaScript3` fork and inside of the `Week1` folder, create a folder called `homework`. Inside of that folder, create a folder called `js-exercises`. For all the following exercises create a new `.js` file in that folder (3 files in total). Make sure the name of each file reflects its content: for example, the filename for exercise one could be `getRandomUser.js`.
1919
2020
**Exercise 1: Who do we have here?**
2121

2222
Wouldn't it cool to make a new friend with just the click of a button?
2323

24-
Write a function that makes an API call to `https://www.randomuser.me/api`
24+
Write a function that makes a HTTP Request to `https://www.randomuser.me/api`
2525

26-
- Inside the same file write two functions: one with `XMLHttpRequest`, and the other with `axios`
27-
- Each function should make an API call to the given endpoint: `https://www.randomuser.me/api`
26+
- Inside the JavaScript file write two functions: one with `XMLHttpRequest`, and the other with `axios`
27+
- Each function should make a HTTP Request to the given endpoint: `https://www.randomuser.me/api`
2828
- Log the received data to the console
29-
- Incorporate error handling
29+
- Incorporate error handling: log to the console the error message
3030

3131
**Exercise 2: Programmer humor**
3232

3333
Who knew programmers could be funny?
3434

35-
Write an function that makes an API call to `https://xkcd.now.sh/?comic=latest`
35+
Write a function that makes a HTTP Request to `https://xkcd.now.sh/?comic=latest`
3636

3737
- Inside the same file write two programs: one with `XMLHttpRequest`, and the other with `axios`
38-
- Each function should make an API call to the given endpoint: `https://xkcd.now.sh/?comic=latest`
38+
- Each function should make a HTTP Request to the given endpoint: `https://xkcd.now.sh/?comic=latest`
3939
- Log the received data to the console
4040
- Render the `img` property into an `<img>` tag in the DOM
41-
- Incorporate error handling
41+
- Incorporate error handling: log to the console the error message
4242

4343
**Exercise 3: Dog photo gallery**
4444

4545
Let's make a randomized dog photo gallery!
4646

47-
Write a function that makes an API call to `https://dog.ceo/api/breeds/image/random`. It should trigger after clicking a button in your webpage. Every time the button is clicked it should append a new dog image to the DOM.
47+
Write a function that makes a HTTP Request to `https://dog.ceo/api/breeds/image/random`. It should trigger after clicking a button in your webpage. Every time the button is clicked it should append a new dog image to the DOM.
4848

4949
- Create an `index.html` file that will display your random image
5050
- Add 2 `<button>` and 1 `<ul>` element, either in the HTML or through JavaScript
5151
- Write two versions for the button functionality: one with `XMLHttpRequest`, and the other with `axios`
52-
- When any one of the 2 buttons is clicked it should make an API call to `https://dog.ceo/api/breeds/image/random`
52+
- When any one of the 2 buttons is clicked it should make a HTTP Request to `https://dog.ceo/api/breeds/image/random`
5353
- After receiving the data, append to the `<ul>` a `<li>` that contains an `<img>` element with the dog image
54-
- Incorporate error handling
54+
- Incorporate error handling: log to the console the error message
5555

5656
## **3. Code along**
5757

5858
Now that you've learned about APIs and how to connect with them, let's apply it in the context of a complete application.
5959

60-
In the following application you'll be making an API call to an external, public API.
60+
In the following application you'll be making a HTTP Request to an external, public API. You'll use that data in order to fetch facts that you'll display in your own application: a Numbers Facts application.
6161

6262
Enjoy!
6363

6464
- [Vanilla JS Numbers Facts App - AJAX & Fetch](https://www.youtube.com/watch?v=tUE2Nic21BA)
6565

6666
## **4. PROJECT: Hack Your Repo I**
6767

68-
In the following three weeks you are going to write a _Single Page Application_ (SPA) that makes use of the [GitHub API](https://developer.github.com/v3/guides/getting-started/).
68+
In the following three weeks you are going to write an application that makes use of the [GitHub API](https://developer.github.com/v3/guides/getting-started/). Each week builds on top of the other, just like a real-world application!
6969

70-
Figure 1 below shows an example of what your application will look like.
70+
[![UI Example](./assets/hyf-github.png)](https://js3-spa.herokuapp.com/)
71+
Click on the image to open up the demo of the application!
7172

72-
![UI Example](./assets/hyf-github.png)
73-
74-
This application does 2 things:
73+
This application, HackYourRepo, does 2 things:
7574

7675
1. It makes connection to the GitHub API and retrieves all the repositories found in the [HackYourFuture account](https://www.github.com/hackyourfuture).
77-
2. It displays those repositories in an alphabetically-oreded list. When a user clicks on any of the repository names it will show more details about it.
78-
79-
### Getting an overview
80-
81-
For this week you're expected to build upon pre-existing code, found in the folder `homework`. Here's what you'll find:
82-
83-
| Filename | Description |
84-
| ------------ | --------------------------------- |
85-
| `hyf.png` | Contains the HackYourFuture logo. |
86-
| `index.html` | The application's HTML file. |
87-
| `index.js` | A starter JavaScript file. |
88-
| `style.css` | A starter CSS file. |
89-
90-
As you'll experience in your job, you'll be exposed to an already existing codebase. It's an essential skill to get used to doing this. But how?
91-
92-
### A first examination
93-
94-
1. Open `index.html` and examine its contents (but don't modify anything). Notice that the HTML `<body>` looks like this:
95-
96-
```html
97-
<body>
98-
<div id="root"></div>
99-
<script src="./index.js"></script>
100-
</body>
101-
```
102-
103-
The `<body>` tag contains a single `<div>` to which you will need to dynamically append HTML elements through your JavaScript code in `index.js`.
104-
105-
2. Open `index.js`. This file contains a starter set of code for you to expand. It contains the following three functions:
106-
107-
| Function | Description |
108-
| ----------------- | ------------------------------------------------------------------------------------------------------------ |
109-
| `fetchJSON` | Uses `XMLHttpRequest` to fetch JSON data from an API end point. This function uses an asynchronous callback. |
110-
| `createAndAppend` | A utility function for easily creating and appending HTML elements. |
111-
| `main` | Contains the start-up code for the application. |
112-
113-
`index.js` also contains a variable with the URL required for fetching information about the HYF repositories:
114-
115-
```js
116-
const HYF_REPOS_URL =
117-
'https://api.github.com/orgs/HackYourFuture/repos?per_page=100';
118-
```
119-
120-
3. Open the `index.html` file in your browser. You will see an unordered list with the names of the HYF repositories.
121-
122-
4. Review the `main()` function in `index.js` and examine how this code fetches the JSON data and calls renders the data as unordered list in the web page.
123-
124-
5. Take a look at the API URL:
125-
126-
```
127-
https://api.github.com/orgs/HackYourFuture/repos?per_page=100
76+
2. It displays those repositories in an alphabetically-ordered list. When a user clicks on any of the repository names it will show more details about it.
77+
78+
In the course of the next 3 weeks you'll be writing the necessary code to make all of this work!
79+
80+
### 4.1 Requirements
81+
82+
To get started, make sure you're in the right GIT branch: `week1-[YOURNAME]`. Then, navigate to the `hackyourrepo-app` folder and become familiar with the files there.
83+
84+
This week you're required to (1) setup the HTML structure of the application. In addition, you are expected to (2) style the application to make it user-friendly.
85+
86+
Here are the requirements for the HTML:
87+
88+
- Include 3 `<section>` tags
89+
- Include a `<select>` tag
90+
- Use the following placeholder data:
91+
92+
```js
93+
const placeholderRepos = [
94+
{
95+
name: 'SampleRepo1',
96+
description: 'This repository is meant to be a sample',
97+
forks: 5,
98+
updated: '2020-05-27 12:00:00',
99+
},
100+
{
101+
name: 'AndAnotherOne',
102+
description: 'Another sample repo! Can you believe it?',
103+
forks: 9,
104+
updated: '2020-05-27 12:00:00',
105+
},
106+
{
107+
name: 'HYF-Is-The-Best',
108+
description:
109+
"This repository contains all things HackYourFuture. That's because HYF is amazing!!!!",
110+
forks: 130,
111+
updated: '2020-05-27 12:00:00',
112+
},
113+
];
128114
```
129115

130-
This URL is special, as it gives us data in JSON format (Try it out in your browser!). This type of URL is also known as an `endpoint`, an address that we can use to send a request to in order to get data. Learn more about endpoints [here](https://smartbear.com/learn/performance-monitoring/api-endpoints/).
131-
132-
Note the query string `?per_page=100` in the above URL. If you don't specify this `query string` you will only get the first 30 repositories (the default `per_page` is 30, which we know because it says so in the [API documentation](https://developer.github.com/v3/#pagination)).
133-
134-
### Week 1 Assignment
135-
136-
The assignment for this week is to produce a functional application that looks similar to Figure 1:
137-
138-
![UI Example](./assets/hyf-github.png)
139-
140-
Functionally, the application should do the following:
141-
142-
1. Make an API call to the endpoint: https://api.github.com/orgs/HackYourFuture/repos?per_page=100
143-
2. Display the first 10 items in the HTML file (write JavaScript to add element to the DOM)
144-
3. Show feedback when an error has happened
145-
146-
Modify the following files:
147-
148-
**1. `index.js`**
149-
150-
- Add new functions and modify function `main()` as you see fit.
151-
- Render network errors to the DOM (see Figure 2 below for an example). Do not use `console.log` as regular users will not see the console output. Instead, create an element that displays the error message in the DOM. Use the predefined `alert-error` class from `style.css` to style your error. It should look like this:
152-
153-
![Error rendering](./assets/hyf-github-error.png)
154-
155-
<small>Figure 2. Rendering of network errors.</small>
156-
157-
**2. `style.css`**
158-
159-
- Add your own CSS styling. Use `style.css` for all of your CSS rules to style the `index.html`. Make sure your UI is responsive. Try it with Chrome Developer Tools in the browser, using a mobile phone format and a tablet format, portrait and landscape.
160-
161-
**You are not allowed to use a CSS library such as Bootstrap.**
162-
163-
**Hints:**
164-
165-
- To sort the list repositories use [`.sort()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) and [`.localeCompare()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
166-
167-
- Use CSS media queries, percentage values and [Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) to make the UI responsive.
116+
Here are the requirements for the CSS:
168117

169-
- To force a `404` network error so that you can test the rendering of errors, change the URL to make an invalid GitHub request, e.g. append an `x` to `orgs`: `orgsx`.
118+
- Make use of `flexbox`
119+
- Make use of `media-queries` and `calc()` to make the page responsive ([mobile, tablet, desktop](https://tinyurl.com/yc5zmste))
170120

171-
Good luck!
121+
Other than this you can create your own version of the page!
172122

173123
## **SUBMIT YOUR HOMEWORK!**
174124

0 commit comments

Comments
 (0)