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

Skip to content

Commit 263ac0e

Browse files
authored
Merge pull request HackYourFuture-CPH#88 from HackYourFuture-CPH/feature/week9-updates
week9 updates and homework weeks update
2 parents 66633a7 + bc9ffe1 commit 263ac0e

File tree

8 files changed

+41
-23
lines changed

8 files changed

+41
-23
lines changed

JavaScript3/Week7/homework.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ Go over your homework one last time:
9090
- Have you used `const` and `let` and avoided `var`?
9191
- Do the variable, function and argument names you created follow the [Naming Conventions](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md)?
9292
- Is your code well-formatted (see [Code Formatting](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md))?
93-
![](https://media.giphy.com/media/l4EpblDY4msVtKAOk/giphy.gif)
93+
-
94+
![check](https://media.giphy.com/media/l4EpblDY4msVtKAOk/giphy.gif)
95+
9496
If you can answer yes to the above questions then you are ready to hand in the homework:<br/>
9597
- Find the hyf-homework git repo (that you have forked from [here](https://github.com/HackYourFuture-CPH/hyf-homework)) the link will be https://github.com/YOUR-ACCOUNT/hyf-homework
9698
- Add your homework files in the Javascript/javascript3/week7 folder

JavaScript3/Week8/homework.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ Go over your homework one last time:
9090
- Does every file run without errors and with the correct results?
9191
- Have you used `const` and `let` and avoided `var`?
9292
- Do the variable, function and argument names you created follow the [Naming Conventions](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md)?
93-
- Is your code well-formatted (see [Code Formatting](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md))?
94-
![](https://media.giphy.com/media/l4EpblDY4msVtKAOk/giphy.gif)
93+
- Is your code well-formatted (see [Code Formatting](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md))?
94+
-
95+
![](https://media.giphy.com/media/l4EpblDY4msVtKAOk/giphy.gif)
96+
9597
If you can answer yes to the above questions then you are ready to hand in the homework:<br/>
9698
- Find the hyf-homework git repo (that you have forked from [here](https://github.com/HackYourFuture-CPH/hyf-homework)) the link will be https://github.com/YOUR-ACCOUNT/hyf-homework
97-
- Add your homework files in the Javascript/javascript3/week7 folder
99+
- Add your homework files in the Javascript/javascript3/week8 folder
98100
- To finish the homework post the link for your repo and the rendered index.html on your classes slack channel
99101
---
100102

JavaScript3/Week8/preparation.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
## Promises
44
- [A cartoon explaining promises](https://kosamari.com/notes/the-promise-of-a-burger-party) (10 min)
5-
- [A nice article from David Walsh](https://davidwalsh.name/promises) (15 min)
5+
- [A nice article about promises from David Walsh](https://davidwalsh.name/promises) (15 min)
6+
- https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/promises.md (15 min)
67
- Everything you want to know about [JavaScript scope](https://toddmotto.com/everything-you-wanted-to-know-about-javascript-scope/) (20 min)
78

89
![You can do it!](https://media.giphy.com/media/yoJC2K6rCzwNY2EngA/giphy.gif)
-114 KB
Binary file not shown.

JavaScript3/Week9/homework.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Using classes help with structuring code. It is one of many **design patterns**. Second it **connects everything** you have learned in js: functions, properties, methods, keys, arrays.
55

66
## Lets make some art using classes
7-
In HTML5 there is an elements called canvas. It works just like a canvas. You can paint elements like lines, circles and much more to the canvas.
7+
In HTML5 there is an elements called canvas. It **works just like a real canvas.** You can paint elements like lines, circles and much more to the canvas.
88

99
### Paint a circle to a canvas element
1010
First add the `canvas` element to your html. Now draw a circle on the `canvas` using js. Google is your friend here :)
@@ -20,9 +20,9 @@ c1.draw();
2020

2121
Where the constructor should look like this: `constructor(x, y, r, startAngle, endAngle, fillColor)`
2222

23-
The circle should have one method: `draw` that draws the circle to the canvas. That means that creating an instance of the circle class will not draw the circle. That first happens when we call the draw method.
23+
The circle should have one method: `draw` that **draws the circle to the canvas**. That means that creating an instance of the circle class will not draw the circle. **Drawing the circle** first happens when we **call the draw method.**
2424

25-
Test if the new class works by creating a circle and drawing it to the canvas. Try some different radiuses and fill colors.
25+
Test if the new class works by creating a circle and drawing it to the canvas. Try some different radiuses, positions and fill colors.
2626

2727
### Now lets make art!
2828
Every half second create a new circle class and draw that to the canvas.
@@ -36,11 +36,11 @@ Instead of the circles just randomly appearing on the screen, make them appear a
3636

3737

3838
## Getting into promises
39-
Lets use the github api to see what repositories different users have. You can use this url to get repositories for a specific github username, in this case the username `benna100`: `https://api.github.com/search/repositories?q=user:benna100`. Select 3 classmates github username that you want to show repositories for.
39+
Lets use the github api to see **what repositories different users have**. You can use this url to get repositories for a specific github username, in this case the username `benna100`: `https://api.github.com/search/repositories?q=user:benna100`. Select 3 classmates github username that you want to show repositories for.
4040

41-
Fetch all the 3 classmates repositories at the same time using Promise.all.
41+
Fetch all the 3 classmates repositories **at the same time using Promise.all.** Remember the **all at once** exercise [here?](../Week8/homework.md#visual-promise)
4242

43-
When you have the data for the different repositories, render the fullname of the repo, url of the repo, and the owner of the repo. See [github-repos](homework/github-repos.html) as an example of how the renderered repos should look.
43+
When you have the data for the different repositories, **render the fullname** of the repo, **url** of the repo, and **the owner** of the repo. See [github-repos](homework/github-repos.html) as an example of how the renderered repos should look. You are more than welcome to style it a bit nicer!
4444

4545
## Shopping cart using Classes
4646
Let's get a bit more into creating classes!
@@ -53,7 +53,6 @@ class Product {
5353
}
5454
}
5555

56-
5756
class ShoppingCart {
5857
constructor(products) {
5958
this.products = products;
@@ -67,6 +66,10 @@ class ShoppingCart {
6766
// Implement functionality here
6867
}
6968

69+
searchProduct(productName) {
70+
// Implement functionality here
71+
}
72+
7073
getTotal() {
7174
// Implement functionality here
7275
}
@@ -89,18 +92,27 @@ So we have two classes. `Product` represents products. `ShoppingCart` represents
8992
### Part 1
9093
Create the functionality for the `ShoppingCart` class.
9194
- `addProduct` should add a product to the products array.
92-
- `removeProduct` should remove a product from the products array. Hint look up indexOf
95+
- `removeProduct` should remove a product from the products array.
9396
- `getTotal` should get the total price of the products in the `shoppingcart`.
9497
- `renderProducts` should render the products to html. You decide what to show and how.
98+
- `searchProduct` should return an array of product that match the `productName` parameter
9599
- `getUser` should return a promise with the data from this api: https://jsonplaceholder.typicode.com/users/1
96100

97101
### Part 2
98102
Try and create some products and call the `addProduct` and the `removeProduct` functions to see if they work.
99103

100104
Call the `getUser` function to get a user. When the user has been fetched. Render the products using the `renderProducts` method. Also render the username and the total price of the products in the `shoppingcart`.
101105

106+
*Optional and a little tricky!* Create a **searchbar where a user can search for a product.** Matching product are shown as an autocomplete. **Clicking a product** in the autocomplete **opens a modal** with product information.
107+
102108
### Part 3
103-
The `Product` class function should get a method called `getPrice`. The function should have `currency` as a parameter. Depending on the currency return the correct price. Add 3 or more curriencies. Or use an api for getting the price dependent on a currency that getPrice uses.
109+
The `Product` class should get a method called `convertToCurrency`. The function should have `currency` as a parameter. Depending on the **provided currency return the correct price** for the product. Add 3 or more curriencies. Or use an api for getting the price dependent on a currency that `convertToCurrency` uses.
110+
111+
```js
112+
// Assuming dkr as default currency
113+
const plant = new Product('plant', 50);
114+
console.log(plant.convertToCurrency('dollars')) // 7.5
115+
```
104116

105117
### Part 4, optional
106118
Be creative! Create some cool/weird/quirky functionality of either the `Product` class or the `ShoppingCart` class.
@@ -117,11 +129,13 @@ Go over your homework one last time:
117129
- Does every file run without errors and with the correct results?
118130
- Have you used `const` and `let` and avoided `var`?
119131
- Do the variable, function and argument names you created follow the [Naming Conventions](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md)?
120-
- Is your code well-formatted (see [Code Formatting](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md))?
121-
![](https://media.giphy.com/media/l4EpblDY4msVtKAOk/giphy.gif)
132+
- Is your code well-formatted (see [Code Formatting](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md))?
133+
-
134+
![check](https://media.giphy.com/media/l4EpblDY4msVtKAOk/giphy.gif)
135+
122136
If you can answer yes to the above questions then you are ready to hand in the homework:<br/>
123137
- Find the hyf-homework git repo (that you have forked from [here](https://github.com/HackYourFuture-CPH/hyf-homework)) the link will be https://github.com/YOUR-ACCOUNT/hyf-homework
124-
- Add your homework files in the Javascript/javascript3/week7 folder
138+
- Add your homework files in the Javascript/javascript3/week9 folder
125139
- To finish the homework post the link for your repo and the rendered index.html on your classes slack channel
126140
---
127141

JavaScript3/Week9/preparation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Preparation
22

3-
- [Understanding JavaScript Constructor functions (factory function)](https://css-tricks.com/understanding-javascript-constructors/) (10 min)
4-
- Promises https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/promises.md (15 min)
3+
- Classes: https://javascript.info/class (15 min)
4+
- More advanced about classes https://flaviocopes.com/javascript-classes/ (10 min)
55

66
_Please go through the material and come to class prepared!_

JavaScript3/Week9/readme.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Learning goals
2-
- [ ] Constructor function
3-
- [ ] Promises advanced (all, race, chaining)
42
- [ ] Classes
3+
- [ ] Promises advanced
54

65
# Relevant links
76
* [Preparation](preparation.md)

JavaScript3/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
| Week | Topic | Preparation | Homework |
44
| ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
55
| 7. | Json <br> Apis <br> Fetch| [Preparation](Week7/preparation.md) | [Homework](Week7/homework.md) |
6-
| 8. | Promises <br> Scoping <br> Debugging| [Preparation](Week8/preparation.md) | [Homework](Week8/homework.md)|
7-
| 9. | Constructor function <br> Promises advanced <br> classes | [Preparation](Week9/preparation.md)| [Homework](Week9/homework.md) |
6+
| 8. | Promises <br> Scoping <br> Debugging| [Preparation](Week8/preparation.md) | [Homework](Week8/homework.md)|
7+
| 9. | Classes <br> Promises advanced | [Preparation](Week9/preparation.md)| [Homework](Week9/homework.md) |

0 commit comments

Comments
 (0)