Skip to content

Commit 7a7fdf3

Browse files
committed
unnested promises
1 parent 7c321cd commit 7a7fdf3

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

functions/4-functions-promise.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ function eatLunch(cannedFood) {
3838
.then(contents => {
3939
console.log('Opened can: ' + contents);
4040
console.log('Warming up: ' + contents);
41-
return warmUp(contents)
42-
.then(hotFood => {
43-
console.log('Warmed up: ' + hotFood);
44-
return eat(hotFood);
45-
});
41+
return warmUp(contents);
42+
})
43+
.then(hotFood => {
44+
console.log('Warmed up: ' + hotFood);
45+
return eat(hotFood);
4646
});
4747
}
4848

functions/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Functions, callbacks, promise and async/await
1+
# Functions, callbacks, promises and async/await
22

33
## Why use functions?
44

@@ -286,10 +286,10 @@ Our `eatLunch()` and `main()` functions can now be rewritten as follows (`consol
286286
function eatLunch(cannedFood) {
287287
return openCan(cannedFood)
288288
.then(contents => {
289-
return warmUp(contents)
290-
.then(hotFood => { console.log('Warmed up: ' + hotFood);
291-
return eat(hotFood);
292-
});
289+
return warmUp(contents);
290+
})
291+
.then(hotFood => {
292+
return eat(hotFood);
293293
});
294294
}
295295

0 commit comments

Comments
 (0)