Skip to content

Commit 39e83ff

Browse files
minor fixes
1 parent c6723d0 commit 39e83ff

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

ebook/07_iterables-and-looping.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ for (const index in fruits){
129129
// gnam gnam
130130
```
131131

132-
Since `for in` will return the value and not the value itself, we need to access with the syntax `fruits[index]`.
132+
Since `for in` will return the index and not the value itself, we need to access with the syntax `fruits[index]`.
133133

134134
As you can see, the `for in` loop returned the value of the property `eat` which we've added after initialization of the variable `fruits`.
135135
On the other hand, the `for of` loop only returned the values that were in the array when we initialized it.

ebook/13_promises.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Chapter 13: Promises
22

33
`JavaScript` work **synchronously** which means that each block of code will be executed after the previous one.
4+
5+
```javascript
6+
const data = fetch('your-api-url-goes-here');
7+
console.log('Finished');
8+
console.log(data);
9+
```
10+
411
In the example above, we're using `fetch` to retrieve data from a url (in this example we're only pretending to be doing so).
512

613
In case of synchronous code we would expect the subsequent line to be called only after the `fetch` has been completed. But in reality, what's going to happen is that `fetch` will be called, and straight away the subsequent two `console.log` will also be called, resulting in the last one `console.log(data)` to return `undefined`.

0 commit comments

Comments
 (0)