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

Skip to content

Commit 965d583

Browse files
authored
Merge pull request HackYourFuture-CPH#69 from HackYourFuture-CPH/the-big-ol-restructure-js-3
The big ol restructure js 3
2 parents dad44b8 + 56fbaed commit 965d583

File tree

16 files changed

+689
-400
lines changed

16 files changed

+689
-400
lines changed

JavaScript2/Week4/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ DOM manipulation
1010
- [ ] Get elements
1111
- [ ] Insert elements
1212
- [ ] Element manipulation (style, innerHTML, text)
13-
- [ ] Windon object
13+
- [ ] Window object
1414
- [ ] Document object
1515

1616
Event listeners

JavaScript3/Week7/homework.md

Lines changed: 60 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,80 @@
11
# Homework Week 7
22

3-
## Step 1: Map, filter, reduce, and =>
3+
## Why should i even do this homework?
4+
Working with json and api's is the way modern **javascript application's communicate with servers**. That can be either getting some data but also updating or creating new data.
45

5-
1. Say you would like to write a program that doubles the odd numbers in an array and throws away the even number.
6+
It is how autocomplete can receive suggestions for a search query and how infinite scroll can keep loading new posts.
67

7-
Your solution could be something like this:
8-
```js
9-
let numbers = [1, 2, 3, 4];
10-
let newNumbers = [];
8+
## Create your own json file
9+
Create your own json file with something that **interests you**. Maybe that could be computers, pets, music etc.
1110

12-
for(let i = 0; i < numbers.length; i++) {
13-
if(numbers[i] % 2 !== 0) {
14-
newNumbers[i] = numbers[i] * 2;
15-
}
16-
}
11+
Remember to validate the json using a tool like fx this: https://jsonlint.com/
1712

18-
console.log("The doubled numbers are", newNumbers); // [2, 6]
13+
## Find a cool api
14+
Find a cool api and **explain how it works** and what kind of **json data** the api responds with. Is it an array, an object, a string. How is the data structure. Is it fx an array of objects or how is it structured.
1915

20-
```
16+
There are a few examples of apis here:
17+
https://github.com/toddmotto/public-apis
2118

22-
rewrite the above program using `map` and `filter` don't forget to use `=>`
19+
## Weather app
20+
Lets create a **weather app** that based on a **users location** can find the relevant weather for that user.
2321

24-
2. Using [this json file](https://gist.githubusercontent.com/pankaj28843/08f397fcea7c760a99206bcb0ae8d0a4/raw/02d8bc9ec9a73e463b13c44df77a87255def5ab9/movies.json) as the source, build a function which does the following:
22+
### Sign up for api key
23+
Go to https://openweathermap.org/appid and **sign up for an api key**. This key we will use for getting access to the weather api.
2524

26-
1. Give each movie a `tag`: Good (>= 7), Average (>= 4 and < 7), Bad (< 4) based on the ratings.
27-
1. Calculate the average rating of all the movies.
28-
1. Count the total number of Good, Average and Bad movies.
29-
1. Count he number of movies containing the following keywords: `["The", "dog", "who", "is", "not", "a", "man"]`. Can you make sure the search is case insensitive?
30-
1. Count the number of movies made between 1980-1989 (including both the years).
25+
### First call to the weather api
26+
We are going to be using the current weather api: https://openweathermap.org/current
3127

32-
## Step 2: Continuing with the previous exercise
28+
To get some data from the api go to https://api.openweathermap.org/data/2.5/weather?q=copenhagen&appid=YOUR_APP_ID, where `YOUR_APP_ID` is substituted with the key you signed up for in the first step.
3329

34-
- Add map, filter, reduce to your existing app to build an application that loads data from github, filters out based on certain value, map->reduces to a data object and render that object to the dom (using map again).
35-
- For example you can try to use map, filter and reduce to show the most and the least forked repositories, watched repositories. And the total number of forks for all repo's. Also you can work with the data provided about the amount of commits or contributers.
36-
- Add a readme to your repo explaining what your app does and how to use your app. Here's a [template](https://gist.github.com/jxson/1784669) and here you can see how to make [your readme awesome](https://gist.github.com/rrgayhart/91bba7bb39ea60136e5c).
30+
If you go to the [above url](https://api.openweathermap.org/data/2.5/weather?q=copenhagen&appid=YOUR_APP_ID) and see some weather json data then congrats 🎉.
3731

38-
## Step 3: **Some freeCodeCamp challenges:**
32+
If not, try and **read the error 💻** and see if you can figure out what went wrong. Or ask in the slack group :)
3933

40-
1. [Comparisons with the Logical And Operator](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-and-operator/)
34+
### Fetch weather data from a city
35+
Create a javascript file and an html file and import the javascript file in the html file.
4136

42-
2. [Record Collection](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/record-collection/)
37+
**Fetch weather json data** from the api using a city a user has specified: Add an **input element** and **a button** to the html. When the button is clicked, get the text from the input (which should be a city name) and fetch the relevant weather data from that city.
4338

44-
3. [Iterate over Arrays with map](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/use-the-map-method-to-extract-data-from-an-array)
39+
Remember to show some **loading text**. What if a user **writes nothing in the input?**
4540

46-
## Step 4: Hand in Homework:
41+
### Display the data
42+
Find some relevant data to show. That could fx be city name, average temperature, how cloudy it is, weather icon etc.
43+
44+
You decide how the data should be displayed. You could maybe be inspired by googling for "weather app ui".
45+
46+
### Your feature here
47+
Now its your time to **come up with a feature**. No matter how big or small.
48+
49+
### Use my current position *optional*
50+
Investigate the [geo location api](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API). Add a button to your page, clicking this button will **get the users current position**. Use that position to fetch weather data.
51+
52+
Hint: We have to change the weather api url, so we are not using city but position. Look into the documentation!
53+
54+
### Save my location *optional*
55+
Imagine if a user did not have to either write a city or click the get my position button, but could just save the location. Lets do that!
56+
57+
When a user has gotten a location through either the input element or the geo location api, save that location using [localstorage](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API). Localstorage is a **way to save data** even when you close the browser.
58+
59+
Now when loading the page and there is a city in the localstorage, use that to get the current weather.
60+
61+
![Weather man](https://media.giphy.com/media/3ohzdJlyD2InWwbJle/giphy.gif)
62+
63+
## Giphy api
64+
Create a site where a **user can search for any word**. When searching a word the application will **find a gif** using the **searched word** using the giphy api: https://developers.giphy.com/docs/
65+
Here is how it is going to work: The user can write some text indicating the gif he is looking for, click a button and then a gif will be found (using the searched word) and the gif will be displayed to the user.
66+
67+
Try break this problem into **smaller problems** and write down how you are going to solve the problem **BEFORE you start coding.**
68+
69+
![Coding](https://media.giphy.com/media/1C8bHHJturSx2/giphy.gif)
70+
71+
## Feedback giving time!
72+
Find a student to give feedback using this site: https://hyf-peer-review.herokuapp.com/
73+
The feedback should be given after the homework has been handed in preferably latest two days after.
74+
75+
To help you get started we have created some ressources about giving feedback. Find them here: https://github.com/HackYourFuture-CPH/curriculum/tree/master/review
76+
77+
## Hand in Homework:
4778
Go over your homework one last time:
4879

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

JavaScript3/Week7/preparation.md

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

3-
- Check the first 3-4 [Videos](https://www.youtube.com/playlist?list=PL0zVEGEvSaeEd9hlmCXrk5yUyqUag-n84). (30 min)
4-
- https://flaviocopes.com/javascript-arrow-functions/ (15 min)
3+
- [JSON](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON) (5 min)
4+
5+
- Read about APIS: https://www.programmableweb.com/api-university/what-are-apis-and-how-do-they-work (10 min)
56

67
![Studying](https://media.giphy.com/media/l0HlAgJTVaAPHEGdy/giphy.gif)
78

JavaScript3/Week7/readme.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Learning Goals
2-
- [ ] Map
3-
- [ ] Reduce
4-
- [ ] Filter
5-
- [ ] Arrow functions
2+
- [ ] Json
3+
- [ ] Apis
4+
- [ ] Fetch (No promise explanation! Focus on usage)
65

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

0 commit comments

Comments
 (0)