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

Skip to content

Commit 4d2ff8c

Browse files
authored
Merge pull request HackYourFuture-CPH#62 from wistoft/patch-1
Fixes for javascript 2 module
2 parents 649052d + f14e598 commit 4d2ff8c

File tree

6 files changed

+75
-31
lines changed

6 files changed

+75
-31
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Get random integer between two numbers, found here: https://stackoverflow.com/a/7228322
3+
* @param {integer} min - The min number
4+
* @param {integer} max - The max number
5+
* @returns {Number} Random number between min and max
6+
*/
7+
function randomIntFromInterval(min, max) {
8+
return Math.floor(Math.random() * (max - min + 1) + min);
9+
}
10+
11+
12+
/**
13+
* Get an array with car objects with random color and speed
14+
* @param {integer} numberOfCars - The number of cars
15+
* @returns {array} Array containing the car objects
16+
*/
17+
function generateCars(numberOfCars) {
18+
const cars = [];
19+
20+
const carMakes = ['Honda', 'BMW','Fiat','Skoda','Volvo'];
21+
const carColors = ['lightgrey', 'lightcyan','lightyellow','lightgreen','lightcoral','lightpink'];
22+
23+
for (let i = 0; i < numberOfCars; i++) {
24+
const car = {};
25+
const randomMakeIndex = randomIntFromInterval(0, carMakes.length - 1);
26+
const randomColorIndex = randomIntFromInterval(0, carColors.length - 1);
27+
28+
car.make = carMakes[randomMakeIndex];
29+
car.color = carColors[randomColorIndex];
30+
car.speed = randomIntFromInterval(0, 100);
31+
32+
cars.push(car);
33+
}
34+
35+
return cars;
36+
}
37+

JavaScript2/Week4/homework.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ First off, congratulations on coming this far, well done!
55
## Step 1: Lets get real comfortable with map, filter and sort.
66

77
Use the carGenerator function to generate 10 cars. The file with the function is here:
8-
[carGenerator.js](/JavaScript2/Week4/classwork/carGenerator.js)
8+
[carGenerator.js](/JavaScript2/Week4/assets/carGenerator.js)
99

1010
You call it like this:
1111
generateCars(10);
@@ -29,12 +29,12 @@ Create the following arrays:
2929
```
3030

3131

32-
## Step 3: Some Challenges
32+
## Step 2: Some Challenges
3333
Let's practice working with Objects and Arrays. Go to FreeCodeCamp and complete all challenges under "Object Oriented and Functional Programming" and the _first four challenges_ under "Basic Algorithm Scripting", up until 'Find the longest word in a string.'
3434
https://www.freecodecamp.org/challenges/store-multiple-values-in-one-variable-using-javascript-arrays
3535

36-
## Step 4: Custom challenge
37-
1. Go to https://api.github.com/orgs/HackYourFuture/repos, you will see a list of the repositories our HYF organization has (yes it's a lot of JSON).
36+
## Step 3: Custom challenge
37+
1. Go to https://api.github.com/orgs/HackYourFuture-CPH/repos, you will see a list of the repositories our HYF organization has (yes it's a lot of JSON).
3838
2. You can copy the JSON and put it in a string at the top of your `.js` file use this tool for that: https://jsonformatter.org/. Copy the json text into the jsonformatter and press this key:
3939
> ![Variables are like boxes](./assets/jsonformatter.PNG)
4040
Now you have a json string you can copy into your file. Now print the name of the 3rd github repository to the console.
@@ -43,7 +43,7 @@ Now you have a json string you can copy into your file. Now print the name of th
4343
5. Use CSS to divide the page in two columns. The left column will have a list of the names for repository. The right column should have the following information about each repository: the number of `stargazers`, the number of `watchers`, the number of `forks`, the `language` of the repository.
4444
6. place the `avatar_url` (logo) of our organization somewhere on a nice place in your page.
4545

46-
## Step 5: Hand in Homework:
46+
## Step 4: Hand in Homework:
4747
Go over your homework one last time:
4848

4949
- Does every file run without errors and with the correct results?

JavaScript2/Week4/review.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Add your favorite person to a list of famous people and show them on a HTML page
170170

171171
For code flow, mentors can use following code and show how everything gets executed using this tool - http://latentflip.com/loupe/
172172

173-
```
173+
```js
174174
function firstFunction() {
175175
for (let i = 0; i < 5; i++) {
176176
console.log(i);
@@ -195,7 +195,6 @@ function secondFunction() {
195195
firstFunction();
196196
```
197197

198-
I also like following exercise from HYF-CPH repo - https://github.com/HackYourFuture-CPH/JavaScript/blob/master/JavaScript2/Week4/code/exercises.js
199198

200199

201200
#### Exercise 2
@@ -207,7 +206,6 @@ Using the planetsFlattened variable:
207206
Console.log jupiters last moon.
208207
```
209208

210-
[JavaScript2/Week4/code/exercises.js](https://github.com/HackYourFuture-CPH/JavaScript/blob/master/JavaScript2/Week4/code/exercises.js)
211209

212210
#### Exercise 3
213211
```

JavaScript2/Week5/homework.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
## Homework Week 5
22

3-
>[Here](/Week5/README.md) you find the readings you have to complete before the sixth lecture.
43

54
### Step 0
65
All share a video or a resource (this can be a drawing, article or a pod cast) that was helpful for you the last few weeks with learning JavaScript. Please share this in the #teach-yourself channel in Slack. Also write as small note about what the resource i about and why you think it's so helpful (you can share more than one if you like).
@@ -94,26 +93,33 @@ Make a website that fetches (= to get) data asynchronously.
9493
9594
2) Add a button (e.g. 'click me') that when clicked `console.logs` 'you clicked me!'
9695
97-
3) Create a function that fetches from [The Github API](https://developer.github.com/v3/). For example from [this page] (https://api.github.com/orgs/HackYourFuture/repos) (the one we used last week). For help on this check this [SO post](https://stackoverflow.com/questions/247483/http-get-request-in-javascript)
96+
3) Create a function that fetches from [The Github API](https://developer.github.com/v3/). For example from [this page](https://api.github.com/orgs/HackYourFuture-CPH/repos) (the one we used last week). For help on this check this [SO post](https://stackoverflow.com/questions/247483/http-get-request-in-javascript)
97+
9898
9999
4) Display the data that you get from the Github API on your web page.
100100
101101
5) Now link the two together: When you click the button -> get the data from the Github API and display it on your website
102102
103-
6) Make all the repositories link their own page in Github. Use the value of the key: `name` to make this work (hint: Github urls always look like this https://api.github.com/repos/HackYourFuture/[repositoryName] where [repositoryName] would be replaced by the actual `name` of the repository, for example `CommandLine`). Make sure the link opens in a new tab.
103+
6) Make all the repositories link their own page in Github. Use the value of the key: `name` to make this work (hint: Github urls always look like this https://api.github.com/repos/HackYourFuture-CPH/[repositoryName] where [repositoryName] would be replaced by the actual `name` of the repository, for example `CommandLine`). Make sure the link opens in a new tab.
104104
105105
7) BONUS: if you look at this:
106106
107107
```js
108-
https://api.github.com/repos/HackYourFuture/CommandLine
108+
https://api.github.com/repos/HackYourFuture-CPH/CommandLine
109109
```
110110
111111
You can see `CommandLine` in the URL. These are called "query parameters" and let us specify in detail what we want from the API. Play around with this. For example you can make two buttons that either get data for a specific repository, JavaScript or Node.js. Or go even more crazy and make users type in a search box 'JavaScript' and then send that to the API by changing the repository.
112112
113-
```
114-
How to hand in your homework:
115-
• Create a new repository "hyf-javascript2". Also create a new folder "week5" inside this repository.
116-
• Upload your homework files inside the week4 folder and write a description for this “commit”.
117-
• Your hyf-javascript2/week5 should now contain the files of your homework.
118-
• Post the link on the slack channel and in the Google Form
119-
```
113+
114+
### Step 4: Hand in Homework:
115+
Go over your homework one last time:
116+
117+
- Does every file run without errors and with the correct results?
118+
- Have you used `const` and `let` and avoided `var`?
119+
- 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+
122+
If you can answer yes to the above questions then you are ready to hand if the homework:
123+
* Find the hyf-homework git repo (forked from [here](https://github.com/HackYourFuture-CPH/hyf-homework))
124+
* Add your homework files in the Javascript/javascript2/week2 folder
125+
* To submit the homework use the link in the top of your classes slack channel.

JavaScript2/Week5/review.md

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

33
```
44
this review covers:
5-
• Git Session
65
• Events
76
• Callbacks
87
• XHTTP Requests

JavaScript2/Week6/homework.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
# Homework Week 6
22

3-
>[Here](/Week6/reading.md) you find the readings you have to complete before the seventh lecture.
4-
53
### Step 1: Feedback
64

7-
Give feedback on `step 3` of `week 5` to one of your fellow students (do this by creating issues in Github).
5+
Give feedback on [step 3 of week 5](https://github.com/HackYourFuture-CPH/JavaScript/blob/master/JavaScript2/Week5/homework.md#step-3-homework-for-javascript) to one of your fellow students (do this by creating issues in Github).
6+
87

98
### Step 2: Fix issues and API
109

1110
- Fix the issues from the last week and make sure you explain how you fixed the issue in a comment (or commit message)
1211
<!-- - Write a script that [polls this API](https://sunrise-sunset.org/api) every 3 seconds and passes a new date every time where date is previous day ++. -->
1312

1413
### Step 3: SPA :sweat_drops:
15-
You are going to write a SPA (Single Page Application) that uses the [Github API](https://developer.github.com/guides/getting-started/). Make sure that your app uses a logical pattern just like [this codepen](http://codepen.io/Razpudding/pen/MmVpeW).
14+
You are going to write a SPA (Single Page Application) that uses the [Github API](https://developer.github.com/guides/getting-started/). Make sure that your app uses a logical pattern just like [this codepen](https://codepen.io/wistoft/pen/KrKyje).
1615

1716
Just like last week:
1817

@@ -91,10 +90,15 @@ Anyway, endless fun and possibilities. Need inspiration, check out the Github AP
9190
__Bonus__: Write a function takes this array `['a', 'b', 'c', 'd', 'a', 'e', 'f', 'c']` and returns an array which only has unique values in it (so it removes the duplicate ones). Make it a 'smart' algorithm that could do it for every array (only strings/number). Try to make it as fast as possible!
9291

9392

94-
```
95-
How to hand in your homework:
96-
• Create a new repository "hyf-javascript2". Also create a new folder "week6" inside this repository.
97-
• Upload your homework files inside the week4 folder and write a description for this “commit”.
98-
• Your hyf-javascript2/week6 should now contain the files of your homework.
99-
• Post the link on the slack channel and in the Google Form
100-
```
93+
### Step 5: Hand in Homework:
94+
Go over your homework one last time:
95+
96+
- Does every file run without errors and with the correct results?
97+
- Have you used `const` and `let` and avoided `var`?
98+
- Do the variable, function and argument names you created follow the [Naming Conventions](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md)?
99+
- Is your code well-formatted (see [Code Formatting](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md))?
100+
101+
If you can answer yes to the above questions then you are ready to hand if the homework:
102+
* Find the hyf-homework git repo (forked from [here](https://github.com/HackYourFuture-CPH/hyf-homework))
103+
* Add your homework files in the Javascript/javascript2/week3 folder
104+
* To submit the homework use the link in the top of your classes slack channel.

0 commit comments

Comments
 (0)