Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Commit

Permalink
Add change from retro / feedback document (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdBarho authored Aug 6, 2024
1 parent a654b00 commit 959bdc2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 34 deletions.
4 changes: 2 additions & 2 deletions lesson04.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ Now change `hour` to `19` and run the code again. What changed?

# Task

Harald invented a game where the player with the highest score wins. The score is the player's height (in cm) plus five times the player's age.
Harald invented a game where the player with the highest score wins. The score is the player's shoe size plus five multiplied by the number of times you ate pizza in the last month.

1. Create variables for the heights and ages for you and a person next to you
1. Create variables for the shoe size and number of pizza eaten for you and a person next to you
1. Calculate the scores for you and your neighbor
1. Decide who wins, output the winner and their score to the `body` of your HTML. Remember: there can be a draw (both players with the same score).

Expand Down
33 changes: 1 addition & 32 deletions lesson15.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ console.log(me.name); // "John"

Let's say we want to transfer the object `me` over the internet. We can't just send the object, because the internet only understands strings.

We could send a string like "Hi my name is John Doe and I like to eat and sleep". But then how would the receiver know what is the name, what is the last name, and what are the hobbies? (No, large language models are not the answer.)
We could send a string like "Hi my name is John Doe and I like to eat and sleep". But then how would the receiver know what is the name, what is the last name, and what are the hobbies?

---

Expand Down Expand Up @@ -126,27 +126,6 @@ OK great, but how can we access that from JavaScript?

---

### The dark past: XMLHttpRequest

```js
let url = "https://something.com/";

function load(url, callback) {
let xhr = new XMLHttpRequest();

xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
callback(xhr.response);
}
};

xhr.open("GET", url, true);
xhr.send(null);
}
```

---

<!-- .slide: id="fetch" -->

# fetch API
Expand All @@ -155,16 +134,6 @@ function load(url, callback) {

- Fetching data from the internet might take a lot of time
- We must not block our browser while waiting for the reply!
- One way around this is to use callbacks. The browser will call our callback function when the data is ready.
- `XMLHttpRequest` was working with callbacks. The API is ugly, error-prone and difficult to use

---

Can you think of something else that is not callbacks? Something that'll help us write code that is easier to read and understand? Something that'll help us avoid callback hell?

No? Neither could the JavaScript community. Until 2017.

<!-- .element: class="fragment" -->

---

Expand Down

0 comments on commit 959bdc2

Please sign in to comment.