├── .eslintrc.json
├── .gitattributes
├── .gitignore
├── .travis.yml
├── .vscode
├── extensions.json
└── settings.json
├── LICENSE
├── README.md
├── Week1
├── LESSONPLAN.md
├── MAKEME.md
├── README.md
├── assets
│ ├── hyf-github-error.png
│ └── hyf-github.png
└── traversy_ajax_crash
│ ├── README.md
│ ├── ajax1.html
│ ├── ajax1.js
│ ├── ajax2.html
│ ├── ajax2.js
│ ├── ajax3.html
│ ├── ajax3.js
│ ├── sample.txt
│ ├── user.json
│ └── users.json
├── Week2
├── LESSONPLAN.md
├── MAKEME.md
├── README.md
├── assets
│ └── week2.png
└── traversy_async_crash
│ ├── README.md
│ ├── callbacks.js
│ ├── index.html
│ └── promises.js
├── Week3
├── LESSONPLAN.md
├── MAKEME.md
├── README.md
├── assets
│ └── JavaScript3_classes.png
├── traversy_fetch_api
│ ├── app.js
│ ├── index.html
│ ├── sample.txt
│ └── users.json
└── traversy_oop_crash
│ ├── 1_basics_literals.js
│ ├── 2_constructor.js
│ ├── 3_prototypes.js
│ ├── 4_inheritance.js
│ ├── 5_object_create.js
│ ├── 6_classes.js
│ ├── 7_subclasses.js
│ ├── README.md
│ ├── assets
│ ├── 2_constructor.png
│ ├── 3_prototypes.png
│ ├── 4_inheritance.png
│ ├── 6_classes.png
│ ├── 7_subclasses.png
│ └── function_proto.png
│ ├── index-all.html
│ ├── index-all.js
│ └── index.html
├── apps
└── hackyourinfo
│ ├── index.js
│ ├── package.json
│ └── yarn.lock
├── assets
├── API.png
├── OOP.png
├── homework-submission.png
├── javascript3.png
├── pokemon-app.gif
├── stasel.png
├── submit-homework.png
├── trivia-app.gif
└── weekflow.png
├── hackyourrepo-app
├── hyf.png
├── index.html
├── script.js
└── style.css
├── hand-in-homework-guide.md
├── package-lock.json
├── package.json
├── prettier.config.js
├── test.md
└── test
├── jest-puppeteer.config.js
├── jest.config.js
├── package-lock.json
├── package.json
└── src
├── config.js
├── fetch-contributors-404.test.js
├── fetch-network-error.test.js
├── fetch-repos-404.test.js
├── helpers.js
├── html-validation.test.js
├── iPhoneX.test.js
└── render.test.js
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": ["airbnb-base", "prettier"],
3 | "plugins": ["prettier"],
4 | "env": {
5 | "browser": true,
6 | "jest": true
7 | },
8 | "globals": {
9 | "page": true,
10 | "browser": true,
11 | "context": true,
12 | "jestPuppeteer": true,
13 | "axios": "readonly"
14 | },
15 | "rules": {
16 | "prettier/prettier": ["error"],
17 | "class-methods-use-this": "off",
18 | "strict": "off",
19 | "no-plusplus": "off",
20 | "linebreak-style": "off",
21 | "no-restricted-syntax": "off",
22 | "no-param-reassign": [
23 | "error",
24 | {
25 | "props": false
26 | }
27 | ]
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Set the default behavior, in case people don't have core.autocrlf set.
2 | * text=auto
3 |
4 | ## For further details please lookup:
5 | ## https://help.github.com/articles/dealing-with-line-endings/#platform-all
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 |
8 | # Runtime data
9 | pids
10 | *.pid
11 | *.seed
12 | *.pid.lock
13 |
14 | # Directory for instrumented libs generated by jscoverage/JSCover
15 | lib-cov
16 |
17 | # Coverage directory used by tools like istanbul
18 | coverage
19 |
20 | # nyc test coverage
21 | .nyc_output
22 |
23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24 | .grunt
25 |
26 | # Bower dependency directory (https://bower.io/)
27 | bower_components
28 |
29 | # node-waf configuration
30 | .lock-wscript
31 |
32 | # Compiled binary addons (http://nodejs.org/api/addons.html)
33 | build/Release
34 |
35 | # Dependency directories
36 | node_modules/
37 | jspm_packages/
38 |
39 | # Typescript v1 declaration files
40 | typings/
41 |
42 | # Optional npm cache directory
43 | .npm
44 |
45 | # Optional eslint cache
46 | .eslintcache
47 |
48 | # Optional REPL history
49 | .node_repl_history
50 |
51 | # Output of 'npm pack'
52 | *.tgz
53 |
54 | # Yarn Integrity file
55 | .yarn-integrity
56 |
57 | # dotenv environment variables file
58 | .env
59 |
60 | .netlify
61 | dist/
62 | iPhoneX.png
63 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - '10'
4 |
5 | script:
6 | - npm run lint
7 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "CoenraadS.bracket-pair-colorizer",
4 | "dbaeumer.vscode-eslint",
5 | "esbenp.prettier-vscode",
6 | "ritwickdey.LiveServer",
7 | "streetsidesoftware.code-spell-checker",
8 | "techer.open-in-browser"
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "editor.formatOnSave": true,
3 | "editor.formatOnType": true,
4 | "editor.formatOnPaste": true,
5 | "editor.detectIndentation": false,
6 | "editor.tabSize": 2,
7 | "cSpell.words": [
8 | "READYSTATE",
9 | "Traversy",
10 | "ajaxcrash",
11 | "networkidle",
12 | "remarcmij",
13 | "tabindex",
14 | "whiteframe"
15 | ],
16 | "deno.enable": false
17 | }
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | This work is licensed under the Creative Commons Attribution 4.0 International License.
2 | To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/
3 | or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DEPRECATED - JavaScript 3
2 | This module has been replace with the Using API's module, find it [here](https://github.com/HackYourFuture/UsingAPIs)
3 |
4 | ```Welcome to JavaScript3! Congratulations on making it this far. You're well on your way to the top!
5 |
6 | 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!
7 |
8 | 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!
9 |
10 | ## Before you start
11 |
12 | In the following weeks we will be using a "style guide" to help you write _"clean code"_. Because code is not only meant to be run by computers, but also to be read by humans (your colleagues, and the future version of you), it's best to make your code good. If your code is readable and nicely formatted, you're doing your colleages (and future you) a great service. The idea of a "style guide" comes from visual design, where companies often have a "visual style". For example, watch the following video to get an idea of this:
13 |
14 | ### Setup Style Guide
15 |
16 | Similar to how designers have style guides for their design work, programmers often have "programming style guides". This is set of rules to follow when writing/formatting your code. The styleguide we'll be using is the one from Airbnb:
17 |
18 | - [Front-end Style Guides](https://fronteers.nl/congres/2015/sessions/front-end-style-guides-anna-debenham)
19 |
20 | The style guide we'll be using is the one from Airbnb:
21 |
22 | - [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript)
23 |
24 | 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.
25 |
26 | We also have tools that can automatically check whether your code is correctly formatted according to a style guide. These tools are called "linters". We will be using the JavaScript linter called "ESLint". The following packages are already added to this repository's `package.json`:
27 |
28 | The required packages you need to install before you write code according to the style guide are the following:
29 |
30 | `json
31 | "eslint"
32 | "eslint-config-airbnb-base"
33 | "eslint-config-prettier"
34 | "eslint-plugin-import"
35 | "eslint-plugin-prettier"
36 | "prettier"
37 | `
38 |
39 | 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:
40 |
41 | `md
42 | npm install
43 | `
44 |
45 | ### Forking the right repository
46 |
47 | 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):
48 |
49 | `bash
50 | foo@bar:~$ git branch week1-YOURNAME
51 | foo@bar:~$ git branch week2-YOURNAME
52 | foo@bar:~$ git branch week3-YOURNAME
53 | `
54 |
55 | Then execute `git checkout week1-YOURNAME` and you can get started!
56 |
57 | If you have any questions or if something is not entirely clear ¯\_(ツ)\_/¯, please ask/comment on Slack!
58 |
59 | ## Learning goals
60 |
61 | In order to successfully complete this module you will need to master the following:
62 |
63 | - Learn what an `Application Programming Interface` (API) is
64 | - Catch up on the `history of JavaScript`
65 | - Understand how to write more readable `asynchronous JavaScript`
66 | - Connect with different `public APIs`
67 | - Build a `Single Page Application` (SPA)
68 | - Work with pre-existing code
69 | - Learn about `Object-Oriented Programming`
70 |
71 | ## How to use this repository
72 |
73 | ### Repository content
74 |
75 | This repository consists of 3 essential parts:
76 |
77 | 1. `README`: this document contains all the required theory you need to understand **while** working on the homework. It contains not only the right resources to learn about the concepts, but also lectures done by HackYourFuture teachers. This is the **first thing** you should start with every week
78 | 2. `MAKEME`: this document contains the instructions for each week's homework. Start with the exercises rather quickly, so that you can ground the concepts you read about earlier.
79 | 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!
80 |
81 | ### How to study
82 |
83 | Let's say you are just starting out with the JavaScript3 module. This is what you do...
84 |
85 | 1. The week always starts on **Wednesday**. First thing you'll do is open the `README.md` for that week. For the first week of `JavaScript3`, that would be [Week1 Reading](/Week1/README.md)
86 | 2. You spend **Wednesday** and **Thursday** going over the resources and try to get a basic understanding of the concepts. In the meanwhile, you'll also implement any feedback you got on last week's homework (from the JavaScript2 module)
87 | 3. On **Friday** you start with the homework, found in the `MAKEME.md`. For the first week of `JavaScript3`, that would be [Week1 Homework](/Week1/MAKEME.md)
88 | 4. You spend **Friday** and **Saturday** playing around with the exercises and write down any questions you might have
89 | 5. **DEADLINE 1**: You'll submit any questions you might have before **Saturday 23.59**, in the class channel
90 | 6. On **Sunday** you'll attend class. It'll be of the Q&A format, meaning that there will be no new material. Instead your questions shall be discussed and you can learn from others
91 | 7. You spend **Monday** and **Tuesday** finalizing your homework
92 | 8. **DEADLINE 2**: You submit your homework to the right channels (GitHub) before **Tuesday 23.59**. If you can't make it on time, please communicate it with your mentor
93 | 9. Start the new week by going back to point 1!
94 |
95 | In summary:
96 |
97 | 
98 |
99 | To have a more detailed overview of the guidelines, please read [this document](https://docs.google.com/document/d/1JUaEbxMQTyljAPFsWIbbLwwvvIXZ0VCHmCCN8RaeVIc/edit?usp=sharing) or ask your mentor/class on Slack!
100 |
101 | ### Video lectures
102 |
103 | For each module HackYourFuture provides you with video lectures. These are made by experienced software developers who know what they're talking about. The main teacher for this module will be [Stasel Seldin](https://hackyourfuture.slack.com/team/UQJGC1MSL): senior iOS developer!
104 |
105 | You can find out more about him here:
106 |
107 | - [GitHub](https://github.com/Stasel)
108 | - [@Stasel on Slack](https://hackyourfuture.slack.com/team/UQJGC1MSL)
109 |
110 | Learn from Stasel in the following playlist of videos he has made for you! (Click on the image to open the link)
111 |
112 |
113 |
114 | ## Planning
115 |
116 | | Week | Topic | Reading Materials | Homework | Lesson Plan |
117 | | ---- | ------------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------- | -------------------------------------- |
118 | | 1. | Application Programming Interface (API), AJAX, Modules & Libraries | [Reading W1](/Week1/README.md) | [Homework W1](/Week1/MAKEME.md) | [Lesson Plan W1](/Week1/LESSONPLAN.md) |
119 | | 2. | Promises, Fetch API, JavaScript Versions, 'this' keyword, Arrow functions | [Reading W2](/Week2/README.md) | [Homework W2](/Week2/MAKEME.md) | [Lesson Plan W1](/Week2/LESSONPLAN.md) |
120 | | 3. | Object-Oriented Programming (OOP), ES6 Classes, Async/await, Thinking like a programmer III | [Reading W3](/Week3/README.md) | [Homework W3](/Week3/MAKEME.md) | [Lesson Plan W1](/Week3/LESSONPLAN.md) |
121 | | 4. | Final JavaScript Test | [Details](test.md) | - | - |
122 |
123 | ## Finished?
124 |
125 | Did you finish the module? High five!
126 |
127 | If you feel ready for the next challenge, click [here](https://www.github.com/HackYourFuture/Node.js) to go to Node.js!
128 |
129 | _The HackYourFuture curriculum is subject to CC BY copyright. This means you can freely use our materials, but just make sure to give us credit for it :)_
130 |
131 | This work is licensed under a Creative Commons Attribution 4.0 International License.```
132 |
--------------------------------------------------------------------------------
/Week1/LESSONPLAN.md:
--------------------------------------------------------------------------------
1 | # Lesson Plan JavaScript3 Week 1
2 |
3 | ## Agenda
4 |
5 | The purpose of this class is to introduce to the student:
6 |
7 | - What are `APIs` and how to interact with them
8 | - What is `AJAX` and how to apply it (`XMLHttpRequest`)
9 | - How to use libraries (`axios`)
10 |
11 | ## Core concepts
12 |
13 | FIRST HALF (12.00 - 13.30)
14 |
15 | ## 1. What are APIs and how to interact with them
16 |
17 | ### Explanation
18 | - APIs are created by providers and used by consumers (BE provider, FE consumer)
19 | - Part of an application that can be communicated with from an outside source
20 | - Connect to it using "endpoints"
21 | - Software well-known APIs (Fb APIs, Twitter APIs, Maps APIs, weather APIs);
22 | - API doesn't care which language or technology is used in the consumer or the provider
23 |
24 | #### Types of APIs:
25 | - Private: for employees only under a company network for internal use.
26 | - Semi-private: for clients who paid for the API.
27 | - Public: for everyone on the web.
28 |
29 | #### Architecture styles of API:
30 | - Single purpose: API that gives a direct and specific service.
31 | - Aggregated API: one API as a wrapper for multiple APIs.
32 | - Web services API: punch of APIs working together to forma whole app.
33 |
34 | #### Basic structure of REST API
35 |
36 | - Endpoint: https://api.example.com
37 | - Endpoint with version: https://api.example.com/v1
38 | - Resources:
39 | * https://api.example.com/v1/users
40 | * https://api.example.com/v1/users/create
41 | * https://api.example.com/v1/users/1
42 | * https://api.example.com/v1/users/1/edit
43 | - Query params:
44 | * https://api.example.com/v1/users?limit=10
45 | ### Example
46 | - Give real life example like (Devices like TV, any machine + electricity power socket interface which provides power to any external device)
47 |
48 | ### Excercise
49 |
50 | ### Essence
51 | - Mostly used to request data from some service
52 | - Communication between software and user needs UI interface but software and software needs API as an interface.
53 |
54 | ## 2. What is `AJAX` and how to apply it (`XMLHttpRequest`)
55 |
56 | ### Explanation
57 | - Before AJAX all page reload for all requests, via refreshing the url in the address bar with the new resource.
58 | - It's a technique, not a technology
59 | - `AJAX` stands for Asynchronous JavaScript and XML
60 | - Nowadays we use `JSON` instead of `XML`
61 | - Fetch data without reloading the page
62 | - The XMLHttpRequest API is defined in the browser (window.XMLHttpRequest)
63 | ### Example
64 | Example using the XMLHttpRequest
65 |
66 | ```javascript
67 | const oReq = new XMLHttpRequest();
68 | oReq.open('GET', `https://api.openweathermap.org/data/2.5/weather?q=${cityName}`);
69 | oReq.send();
70 | oReq.addEventListener('load', function (event) {
71 | const data = JSON.parse(this.response);
72 | if (data.cod >= 400) {
73 | // error
74 | console.log(data.message);
75 | } else {
76 | //success
77 | console.log(data.coord.lat);
78 | }
79 | });
80 |
81 | // or another way of getting data
82 | oReq.load = function (event) {
83 | // use oReq.response or this.response
84 | const data = JSON.parse(this.response);
85 | if (data.cod >= 400) {
86 | // error
87 | console.log(data.message);
88 | } else {
89 | //success
90 | console.log(data.coord.lat);
91 | }
92 | };
93 |
94 | ```
95 |
96 | ### Excercise
97 |
98 | Steps of doing the following example:-
99 | ** Install the live server plugin in VS (go to plugins -> live server -> install)
100 | 1. Create self-invoked function to wrap your code
101 | 2. Create an object instance of `XMLHttpRequest`
102 | 3. Call the `open` function to fill it with the Request URL and the request Method
103 | 4. Call the `send` function to make the request
104 | 5. Add event listener with a callback for the sucess event `load`
105 |
106 | ### Essence
107 |
108 | SECOND HALF (14.00 - 16.00)
109 |
110 | ## 3. How to use libraries (`axios`)
111 |
112 | ### Explanation
113 | - A library is a code solution a developer (or a team) has written to a common problem
114 | - Usually open-source
115 | - Helps to solve a problem within an application
116 | - Read the documentation on how to use it
117 | ### Example
118 | Same example but using axios
119 | ```javascript
120 | axios
121 | .get(`https://api.openweathermap.org/data/2.5/weather?q=${cityName}`)
122 | .then(function (response) {
123 | // handle success
124 | console.log(response.data);
125 | }).catch(function (error) {
126 | // handle error
127 | console.log(error);
128 | }).finally(function () {
129 | // always be executed
130 | console.log('I am always here')
131 | });
132 | ```
133 |
134 | > Note: Give example at the end with binding/showing these data in a DOM element like a
or a list instead of only showing them on the console using console.log.
135 |
136 | ### Excercise
137 | ### Essence
138 |
139 |
140 |
141 |
142 |
--------------------------------------------------------------------------------
/Week1/MAKEME.md:
--------------------------------------------------------------------------------
1 | # Homework JavaScript3 Week 1
2 |
3 | ## **Todo list**
4 |
5 | 1. Practice the concepts
6 | 2. JavaScript exercises
7 | 3. Code along
8 | 4. PROJECT: Hack Your Repo I
9 |
10 | ## **1. Practice the concepts**
11 |
12 | This week's concepts can be challenging, therefore let's get an easy introduction using some interactive exercises! Check the following resources out and start practicing:
13 |
14 | - [Learn JavaScript: Requests](https://www.codecademy.com/learn/introduction-to-javascript/modules/intermediate-javascript-requests)
15 |
16 | ## **2. JavaScript exercises**
17 |
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`.
19 |
20 | **Exercise 1: Who do we have here?**
21 |
22 | Wouldn't it cool to make a new friend with just the click of a button?
23 |
24 | Write a function that makes a HTTP Request to `https://www.randomuser.me/api`
25 |
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`
28 | - Log the received data to the console
29 | - Incorporate error handling: log to the console the error message
30 |
31 | **Exercise 2: Programmer humor**
32 |
33 | Who knew programmers could be funny?
34 |
35 | Write a function that makes a HTTP Request to `https://xkcd.now.sh/?comic=latest`
36 |
37 | - Inside the same file write two programs: one with `XMLHttpRequest`, and the other with `axios`
38 | - Each function should make a HTTP Request to the given endpoint: `https://xkcd.now.sh/?comic=latest`
39 | - Log the received data to the console
40 | - Render the `img` property into an `` tag in the DOM
41 | - Incorporate error handling: log to the console the error message
42 |
43 | **Exercise 3: Dog photo gallery**
44 |
45 | Let's make a randomized dog photo gallery!
46 |
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.
48 |
49 | - Create an `index.html` file that will display your random image
50 | - Add 2 `