-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close #5
- Loading branch information
Aurélien Allienne
committed
Jan 23, 2018
1 parent
a1fbb80
commit 9c6cf69
Showing
1 changed file
with
14 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,44 @@ | ||
function exercise1Fn () { | ||
let exercise1 = new Promise(() => { | ||
let exercise1 = new Promise((resolve) => { | ||
/* votre solution ici */ | ||
setTimeout(resolve('I love promise'), 500); | ||
}); | ||
|
||
return exercise1./* votre solution ici */ | ||
return exercise1.then(value => console.log(value))/* votre solution ici */ | ||
} | ||
|
||
function exercise2Fn () { | ||
let exercise2 = new Promise(() => { | ||
let exercise2 = new Promise((resolve, reject) => { | ||
/* votre solution ici */ | ||
setTimeout(reject('I hate rejection'), 500) | ||
}); | ||
|
||
return exercise2./* votre solution ici */ | ||
return exercise2.catch(reason => console.log(reason))/* votre solution ici */ | ||
} | ||
|
||
function exercise3Fn () { | ||
let exercise3 = Promise.resolve(1); | ||
|
||
function plusFive(value) { | ||
/* votre solution ici */ | ||
return value + 5 | ||
} | ||
|
||
function multiplyByTwo(value) { | ||
/* votre solution ici */ | ||
return value * 2 | ||
} | ||
|
||
function minusFour(value) { | ||
/* votre solution ici */ | ||
return value - 4 | ||
} | ||
|
||
return exercise3./* votre solution ici */; | ||
return exercise3/* votre solution ici */ | ||
.then(plusFive) | ||
.then(multiplyByTwo) | ||
.then(minusFour); | ||
|
||
} | ||
|
||
module.exports = {exercise1Fn, exercise2Fn, exercise3Fn}; |