Skip to content

Commit

Permalink
Good example of passing data through a 5 promise chain.
Browse files Browse the repository at this point in the history
  • Loading branch information
atom-box committed Oct 22, 2021
1 parent 916d21d commit 80dfcc6
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions chainSimple.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
let a = function(x) {
console.log(x + 'a');
return new Promise (function(resolve, tin){
x += " mercury";
resolve(x);
})
}

let b = function(x) {
console.log(x + 'b');
return new Promise (function(resolve, tin){
x += " venus";
resolve(x);
})
}
let c = function(x) {
console.log(x + 'c');
return new Promise (function(resolve, tin){
x += " earth";
resolve(x);
})
}
let d = function(x) {
console.log(x + 'd');
return new Promise (function(resolve, tin){
x += " mars";
resolve(x);
})
}


a('Stoughton ')
.then(b)
.then(c)
.then(d)
.then((x) => {console.log("big payoff is: "); console.log(x); })

0 comments on commit 80dfcc6

Please sign in to comment.