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

Skip to content

Commit 901b664

Browse files
committed
update homework js2
1 parent 68f0094 commit 901b664

File tree

3 files changed

+39
-38
lines changed

3 files changed

+39
-38
lines changed

javascript2/week1/homework.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ This will create and checkout the branch so you are ready make commits to it
2929
**Interacting with the DOM is a crucial part** of building a website. If we cannot interact with the DOM and the javascript we write cannot be used in a browser. **Connecting javascript to the browser opens up a new world of possibilities** where only the imagination is the limiting factor.
3030

3131
## Overview of homework
32-
1. **Problem solving cardio:** Warmup exercise that includes
32+
1. **[Problem solving cardio:](#1-problem-solving-cardio)** Warmup exercise that includes
3333
- Find the shortest word
3434
- Find and count the Danish letters
3535

36-
2.**Spirit animal name generator:** Create an interactive page where the user can enter the name and receive a spirit animal name
36+
2.**[Spirit animal name generator:](#2-spirit-animal-name-generator)** Create an interactive page where the user can enter the name and receive a spirit animal name
3737

38-
3. 🌟 **hyfBay:** It's a single-page app where users can search for products. We will be building this website step by step over this course.
38+
3. 🌟 **[hyfBay:](#hyfbay)** It's a single-page app where users can search for products. We will be building this website step by step over this course.
3939

40-
## Problem solving cardio
40+
# 1. Problem solving cardio
4141

4242
Lets exercise our problem solving abilities!
4343

4444
![mind exercise](https://media.giphy.com/media/l41m04gr7tRet7Uas/giphy.gif)
4545

46-
### Find the shortest word
46+
## 1.1. Find the shortest word
4747

4848
Write a function that finds the shortest word of an array of words
4949

@@ -52,7 +52,7 @@ const danishWords = ["bil", "plante", "kaffe", "bog", "ø", "planetarium"];
5252
notThisFunctionName(danishWords); // returns 'ø'
5353
```
5454

55-
### Find and count the Danish letters
55+
## 1.2. Find and count the Danish letters
5656

5757
Find the individual number and the total number of Danish letters in a string.
5858

@@ -64,32 +64,32 @@ const danishString2 = "Blå grød med røde bær";
6464
notThisFunctionName(danishString2); // returns {total: 4, æ: 1, ø: 2, å: 1}
6565
```
6666

67-
## Spirit animal name generator
67+
# 2. Spirit animal name generator
6868

6969
Let's create a page where **a user writes his name** in an input element. The user then clicks a button. The user will now **receive a spirit animal name**, fx Benjamin - The fullmoon wolf.
7070

71-
### Markup time!
71+
## 2.1. Markup time!
7272

7373
Create an input element, a button and a tag to display the spirit animal into.
7474

75-
### Setting up the events
75+
## 2.2. Setting up the events
7676

7777
When the user clicks the button, get the name the user wrote in the input field.
7878

79-
### Spirit animal part
79+
## 2.3. Spirit animal part
8080

8181
Now we can get the users name, next step is to **add the spirit animal string** and display that the users name, a dash and then the spirit animal. Fx Name: Peter: Peter - The crying butterfly
8282
For creating the spirit animal create an array with 10 string representing spirit animals. Now get a random item in the array that will represent the spirit animal.
8383

84-
### New spirit animal
84+
## 2.4. New spirit animal
8585

8686
Now a user tells us that he wants a new spirit animal. No problem we say. Let's create functionality where a user can press a button and then get a new spirit animal.
8787

88-
### No input
88+
## 2.5. No input
8989

9090
What if the user clicks the generate new spirit animal and there is no text in the input?
9191

92-
### Event types - _Optional and a little tricky_
92+
## 2.6. Event types - _Optional and a little tricky_
9393

9494
Give the user the possibility to select **when the spirit animal should be created**. Should it be when the user clicks the button or when the user hovers the input field or when text is written in the input field?
9595

@@ -99,25 +99,25 @@ An example is: A user select that she only wants to generate a spirit animal whe
9999

100100
![Spiritanimal](https://media.giphy.com/media/IMSq59ySKydYQ/giphy.gif)
101101

102-
## hyfBay - get the okay'est products here
102+
# 3. hyfBay - get the okay'est products here <a id='hyfbay'></a>
103103

104104
We have been **hired for a company** to do a SPA - Single Page App for them. It is a website where a user can search for products. The products can also be **filtered and sorted** based on what products the user wants to see.
105105

106106
We are going to be building this website step by step, so have patience :)
107107

108-
### Lets get started!
108+
## 3.1. Lets get started!
109109

110110
In the [homework/hyf-bay folder](homework/hyf-bay) there is a project template you should continue working on. So copy all the files into your `hyf-homework/javascript/javascript2/week1` folder.
111111

112112
The `index.html` is very basic. It simply loads two javascript files and include some css. The two javascript files are `hyfBayHelpers.js` and the `main.js`. `hyfBayHelpers.js` contains a function (`getAvailableProducts`) that we can use to get an array of products. In the `main.js` we will be writing all our code!
113113

114-
#### Requirements
114+
## 3.2. Requirements
115115

116116
- Using the `getAvailableProducts` array we will render an html list of products
117117
- The list should contain `title`, `price` and `rating`
118118
- The list of products should be generated through calling a function called `renderProducts(products)`
119119

120-
#### Example
120+
### Example
121121

122122
```js
123123
const products = getAvailableProducts();
@@ -131,7 +131,7 @@ renderProducts(products); // This should create the ul and the li's with the ind
131131

132132
So after calling the `renderProducts` function, the output should be like the output you can see here: https://codesandbox.io/s/hyf-bay-first-week-oml13
133133

134-
#### So how can i do that?
134+
### So how can i do that?
135135

136136
Here is a possible way to render the products
137137

javascript2/week2/homework.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ The warmup exercises will be a bit abstract. But the in the **hyfBay exercise**
3737
Javascript is getting difficult now and we are aware of that! Take some time to appreciate how far you have come that last 6 weeks. Instead of comparing yourself to others, compare yourself to where you were a some time ago. If you are seeing progress then you are doing it right 💪
3838

3939
## Overview of homework
40-
1. **Warmup array exercises:** Warmup exercise that includes
40+
1. **[Warmup array exercises:](#1-warmup-array-exercises)** Warmup exercise that includes
4141
- Doubling the number
4242
- ⭐ Working with movies
4343

44-
2. 🌟 **hyfBay:** It's a single-page app where users can search for products.
44+
2. 🌟 **[hyfBay](#hyfbay):** It's a single-page app where users can search for products.
4545

46-
## Warmup array exercises
46+
# 1. Warmup array exercises
4747

4848
If you struggle to do this weeks homework there are a couple of things to do:
4949

5050
- Try watch this video: https://www.youtube.com/watch?v=Urwzk6ILvPQ
5151
- Watch the class recording. If it for some reason is missing. Then watch these: [part 1](https://www.youtube.com/watch?v=AJt_O0EFDC8), [part 2](https://www.youtube.com/watch?v=4tj7CvD7ka8), [part 3](https://www.youtube.com/watch?v=CO40FG6pK2k) [part 4](https://www.youtube.com/watch?v=eA2tCs0AaaM)
5252
- Read up on array functions [here](https://github.com/HackYourFuture-CPH/JavaScript/blob/main/javascript2/week2/readme.md#array-methods-map-filter-and-sort)
5353

54-
### Doubling of number
54+
## 1.1. Doubling of number
5555

5656
Say you would like to write a program that **doubles the odd numbers** in an array and **throws away the even number**.
5757

@@ -72,7 +72,7 @@ console.log("The doubled numbers are", newNumbers); // [2, 6]
7272

7373
Rewrite the above program using `map` and `filter` don't forget to use arrow functions.
7474

75-
### Working with movies
75+
## 1.2. Working with movies
7676

7777
![cinema](https://media.giphy.com/media/l6mBchxYZc7Sw/giphy.gif)
7878

@@ -88,11 +88,11 @@ Copy the movies array in the [movies](homework/movies.js) file. Use this array t
8888
8. Calculate the **average rating** of all the movies using [reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce). _Optional_
8989
9. **Count the total number** of Good, Average and Bad movies using [reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce). A return could fx be `{goodMovies: 33, averageMovies: 45, goodMovies: 123}` _Optional_
9090

91-
## hyfBay - get the okay'est products here - continued
91+
# 2. hyfBay - get the okay'est products here - continued <a id='hyfbay'></a>
9292

9393
**Continue work on your homework regarding the Hyfbay** from previous week. Please copy the files from last week into this weeks `hyf-homework` folder and continue working there. If you have not made last weeks homework the solution for it is included in [this weeks homework folder](homework/hyf-bay) in the `main.js` file.
9494

95-
### Filter products
95+
## 2.1. Filter products
9696

9797
A very normal usecase for a product site is that a **user wants to search for some product** or find products that are cheaper than a set price. Lets implement that functionality for a user!
9898

@@ -108,7 +108,7 @@ Lets get a little closer to javacript:
108108
2. `.filter` on the products array
109109
3. `renderProducts` with the filtered array
110110

111-
#### Searching for products
111+
## 2.2 Searching for products
112112

113113
A user needs to search for products. That means that we need to add an input element to the html.
114114

@@ -120,25 +120,25 @@ Use the overview shown above and the `renderProducts` function.
120120

121121
![Searching for a product](homework/hyf-bay-searching.gif)
122122

123-
#### Filter products based on max price
123+
## 2.3. Filter products based on max price
124124

125125
Lets help a user to find cheap products! When the **user writes a maximum price** the products should be filtered to match that maximum price
126126

127127
_Hint: Break this task into smaller tasks!_
128128

129129
![Searching for a product](homework/hyf-bay-price.gif)
130130

131-
#### Make the website look nicer!
131+
## 2.4. Make the website look nicer!
132132

133133
The website looks awful now, **but** luckily you have had css and html and know exactly what it takes to make this website shine!
134134

135135
Improve it how you see fit. Maybe add a footer, header, logo, title, styling, responsivity. Whatever you feel like would improve the site!
136136

137-
### Create some extra feature
137+
## 2.5. Create some extra feature
138138

139139
No matter how small or how big. Create some feature that would be **cool/helpful/quirky/funny**.
140140

141-
### Sort the products - _optional_
141+
## 2.6 Sort the products - _optional_
142142

143143
This task is more open ended! So you need to come up with fx how the user should interact with the functionality.
144144

javascript2/week3/homework.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,19 @@ Working with functions in javascript is such an essential part of working with j
3131
We want you to realise that **functions are just variables** in javascript. It is exactly the same as string or a number. This homework forces you into using functions in weird ways that forces you to think differently about functions.
3232

3333
## Overview of homework
34-
1. **Warmup:** Warmup exercise that includes
34+
1. **[Warmup:](#1-warmup)** Warmup exercise that includes
3535
- ⭐ Create a function to make delay in logging out text
3636
- calling a function within a function
3737
- ⭐ Log out location
3838
- Implement runAfterDelay function
3939
- Simulate double click with click event
4040
- Implement joke creator
41-
- ⭐ Function as a variable
4241

43-
2. 🌟 **The fastest presser in this realm:** It's a game where two people compete about who can press a key most often.
42+
2. **[Function as a variable:](#2-function-as-a-variable)**
4443

45-
## Warmup
44+
3. 🌟 **[The fastest presser in this realm:](#3-the-fastest-presser-in-this-realm)** It's a game where two people compete about who can press a key most often.
45+
46+
# 1. Warmup
4647

4748
If you struggle to do this weeks homework there are a couple of things to do:
4849

@@ -79,7 +80,7 @@ The warmup is a **little abstract**, it will get more concrete later on!
7980

8081
9. Create a function called `jokeCreator` that has three parameters: `shouldTellFunnyJoke` - boolean, `logFunnyJoke` - function and `logBadJoke` - function. If you set `shouldTellFunnyJoke` to `true` it should call the `logFunnyJoke` function that should log out a funny joke. And vice versa.
8182

82-
### Function as a variable
83+
# 2. Function as a variable
8384

8485
Create funtions that are used in these different ways:
8586

@@ -91,7 +92,7 @@ Yes i know that was a little tough, now on to the fun part 🎉
9192

9293
![phew](https://media.giphy.com/media/EDt1m8p5hqXG8/giphy.gif)
9394

94-
## The fastest presser in this realm
95+
# 3. The fastest presser in this realm
9596

9697
Lets create a fun simple game :)
9798

@@ -111,7 +112,7 @@ You can implement it exactly like you want to, but here is my recommended order:
111112
4. **Keep a counter** for how many times `l` and `s` was pressed.
112113
5. **Now put it all together!** After the timeout is done figure out which of the counters is largest. Give some kind of feedback to the users indicating who won.
113114

114-
### Extra features
115+
## 2.1 Extra features
115116

116117
1. **Start a new game** functionality. Create some functionality so that the users can restart a game.
117118
2. Try and give the site some **styling so it looks nice** :)
@@ -125,7 +126,7 @@ Here are some general things to consider:
125126
- What if no time was specified for the game?
126127
- What if there were no key presses before the game ends?
127128

128-
### Confetti
129+
## 3.3 Confetti
129130

130131
If you wanna give the game some confetti like in the gif, check out [this library](https://www.npmjs.com/package/confetti-js)
131132

0 commit comments

Comments
 (0)