Skip to content

Commit 566fa64

Browse files
committed
2 parents 23784be + 7d6c81b commit 566fa64

7 files changed

Lines changed: 126 additions & 24 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ or links, please share them by [opening a pull request](https://github.com/FooCo
55

66
Here you can find course content and homework for the JavaScript2 module
77

8-
|Week|Topic|Read|Homework|
9-
|----|-----|----|--------|
8+
|Week|Topic|Read|Homework|Lecture Notes|
9+
|----|-----|----|--------|--------|
1010
|1.|• Capturing user input through forms <br>• [Events](http://javascript.info/introduction-browser-events)<br>• [Basic DOM manipulations](../../../fundamentals/blob/master/fundamentals/DOM_manipulation.md)<br>• [Code debugging using the browser](http://javascript.info/debugging-chrome) <br>• [Code commenting](../../../fundamentals/blob/master/fundamentals/code_commenting.md)<br>• Structuring code files<br>• [Code formatting](../../../fundamentals/blob/master/fundamentals/code_formatting.md)<br>• [Handing in homework via PR](../../..//fundamentals/blob/master/fundamentals/homework_pr.md) |[Reading Week 1](/Week1/README.md)|[Homework Week 1](/Week1/MAKEME.md)|
11-
|2.|• Functions + JSON/Arrays<br>• [Array Manipulations](../../../fundamentals/blob/master/fundamentals/array_manipulation.md)<br>• JSON<br>• [Map and filter](../../../fundamentals/blob/master/fundamentals/map_filter.md)<br>• Arrow functions |[Reading Week 2](/Week2/README.md)|[Homework Week 2](/Week2/MAKEME.md)|
11+
|2.|• Functions + JSON/Arrays<br>• [Array Manipulations](../../../fundamentals/blob/master/fundamentals/array_manipulation.md)<br>• JSON<br>• [Map and filter](../../../fundamentals/blob/master/fundamentals/map_filter.md)<br>• Arrow functions |[Reading Week 2](/Week2/README.md)|[Homework Week 2](/Week2/MAKEME.md)|[Notes](/Week2/LECTURENOTES.md)
1212
|3.|[Closures](../../../fundamentals/blob/master/fundamentals/scope_closures_this.md) <br>• Callbacks|[Reading Week 3](/Week3/README.md)|[Homework Week 3](/Week3/MAKEME.md)|
1313

1414
## Test

Week2/LECTURENOTES.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
### Lecture Notes Week 2
2+
3+
#### Before class
4+
Slack message students for things they'd like to review before diving into new topics
5+
6+
## Reviewing (11-11:30am)
7+
Cover individual topics that students may still be stuck on from previous lectures and homework
8+
9+
## JSON (11:30am-12pm)
10+
* Illustration on Google Maps. How do people from Sweden speak to people from Sri Lanka?
11+
* [Advice Slip](https://adviceslip.com/) and [API](https://api.adviceslip.com/#endpoint-random). If they have machines that run on the programming language RUST, how can we communicate with them? They serialize their data to JSON!
12+
* Douglass Crawford
13+
* What is JSON?
14+
* Javscript Object Notation
15+
* We are fortunate that it's familiar and easy to understand :)
16+
* It is a STRING [PokeAPI](https://pokeapi.co/api/v2/pokemon/squirtle/)
17+
* Not all javascript objects are valid json
18+
* Coding exercise (lecture-exercise.js)
19+
* JSON.parse
20+
* Serialization vs Deserialization
21+
* JSON.stringify()
22+
* Other formats
23+
* protobufs
24+
* XML
25+
* GRPC?!
26+
* Cover homework question #3
27+
28+
## Functions advanced (12-12:30pm)
29+
* Different ways functions can be made:
30+
* function declaration vs expression
31+
* arrow function
32+
* Omitting return, parameter parenthesis
33+
* What's a method?
34+
* Pure function? or side effects?
35+
* Example: how does a program run this? (example w/ a function, call of that function, and a console log)
36+
* Call stack (stack overflow)
37+
* Params
38+
* Extra params
39+
* Default params
40+
* Recursion (basic example)
41+
* Example function
42+
* pigs example?
43+
* countChar("kakkerlak", "k")? With DOM manipulation?
44+
* Simplicity of functions
45+
* while loop from [Chapter 5](http://eloquentjavascript.net/05_higher_order.html)
46+
* Higher order functions
47+
* repeat(n, action)
48+
* greaterThan10
49+
50+
## Array Manipulations
51+
## Map, Filter, Reduce (others? every, some, etc)

Week2/MAKEME.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
```
44
Topics discussed this week:
5-
• Functions + JSON/Arrays
6-
• Array Manipulations
75
• JSON
8-
• Map and filter
9-
• Arrow functions
6+
• Functions advanced
7+
• Array Manipulations
8+
• Map, filter, & reduce
109
```
1110

1211
> [Here](/Week3/README.md) you find the readings you have to complete before the third lecture.
@@ -139,7 +138,13 @@ If that's the case, try and fix the error. When done, run the tests again: `npm
139138

140139
Repeat the previous step until all (= 2 in this case) tests pass.
141140

142-
## Step 3: ROVER
141+
## Step 3: JSON parsing
142+
143+
1. Create an HTML file
144+
2. Insert a script tag that points to squirtle-sprites.js
145+
3. In squirtle-sprites.js, call fetchPokemonData() and convert the JSON string it returns to a javascript object so you can access its properties
146+
4. Display the sprite images (located in the parsed object) in the HTML page. You'll need to do some DOM manipulation kinda of stuff (maybe element.appendChild?)
147+
*Bonus Challenge*: Can you use an array method to loop over all sprites so you don't have to manually type each?
143148

144149
Finish up to chapter 7: JSON on [roverjs.com](http://roverjs.com/)!
145150

@@ -171,3 +176,6 @@ Go over your homework one last time:
171176
If the answer is 'yes' to all preceding questions you are ready to follow these instructions:
172177

173178
- [Handing in homework](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/homework_pr.md)
179+
180+
### Do you have even more time?
181+
Read the _Eloquent Javascript_ chapters in the [Week 2 Readme](./README.md)

Week2/README.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,32 @@
44

55
```
66
In week two we will discuss the following topics:
7-
• Functions + JSON/Arrays
8-
• Array Manipulations
97
• JSON
10-
• Map and filter
11-
• Arrow functions
8+
• Functions advanced
9+
• Array Manipulations
10+
• Map, filter, & reduce
1211
```
1312

1413
## Here are resources that we like you to read as a preparation for the coming lecture.
1514

1615
### JSON
17-
- [JSON](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON) (MDN)
16+
- [FreeCodeCamp JSON](https://www.youtube.com/watch?v=B-k76DMOj2k)
17+
- [What is JSON and why does one use it?](https://www.quora.com/What-is-JSON-and-why-does-one-use-it/answer/Prid-Speed?ch=10&share=0b6f9763&srid=XxbK)
1818

1919
### Map and Filter
2020
- :dizzy: [Fun fun functional](https://www.youtube.com/playlist?list=PL0zVEGEvSaeEd9hlmCXrk5yUyqUag-n84) :dizzy: Check the first 3-4 videos.
2121

22-
### Code conventions
23-
- Code conventions: http://crockford.com/javascript/code.html
24-
2522
### Array cardio
2623
- Wes Bos' awesome free tutorials. Just make a free account and do Array Cardio #1 [here](https://javascript30.com/)
2724

28-
### From _Eloquent JavaScript_
29-
30-
- Objects continued: http://eloquentjavascript.net/06_object.html
31-
32-
3325
## Recommended readings
26+
These chapters from _Eloquent JavaScript_ are a bit advanced, but give in-depth explanations of the topics that will be discussed during the lecture. If you have the time, try giving these chapters a read.
3427

35-
This chapter from _Eloquent JavaScript_ gives in-depth explanations of the topics that will be discussed during the lecture. Highly recommended (if time permits).
28+
- Chapter 3 - [Functions](https://eloquentjavascript.net/03_functions.html)
29+
- Chapter 4 - [Data Structures: Objects and Arrays](https://eloquentjavascript.net/04_data.html)
30+
- Chapter 5 [Higher-Order Functions](https://eloquentjavascript.net/05_higher_order.html)
3631

37-
- Chapter 3 - [Functions](http://eloquentjavascript.net/03_functions.html)
38-
- Chapter 5 - [Higher-Order Functions](http://eloquentjavascript.net/05_higher_order.html)
32+
#### For fun
33+
[The Weird History of JavaScript](https://www.youtube.com/watch?v=Sh6lK57Cuk4) shows just how haphazard the evolution of Javascript actually was.
3934

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

Week2/example.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>Sample exercise</title>
6+
<style>
7+
body {
8+
font-family: sans-serif;
9+
}
10+
#advice {
11+
color: slateblue;
12+
}
13+
</style>
14+
</head>
15+
<body>
16+
<h3>Here is your advice for the day:</h3>
17+
<h1 id="advice"></h1>
18+
<script type="text/javascript" src="./lecture-exercises.js"></script>
19+
</body>
20+
</html>

Week2/homework/squirtle-sprites.js

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Week2/lecture-exercises.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
async function getRandomAdvice() {
2+
const adviceReq = fetch('https://api.adviceslip.com/advice'); // send request
3+
const adviceResponse = await adviceReq; // wait until something comes back
4+
// const jsonString = await adviceResponse.text();
5+
// return jsonString
6+
// const adviceData = JSON.parse(jsonString)
7+
// return jsonString
8+
const adviceData = await adviceResponse.json(); // parses JSON string into native JavaScript object
9+
return adviceData.slip.advice;
10+
}
11+
12+
async function setRandomAdvice() {
13+
const adviceEl = document.getElementById('advice');
14+
adviceEl.innerText = await getRandomAdvice();
15+
}
16+
17+
setRandomAdvice();

0 commit comments

Comments
 (0)