Created
September 3, 2015 16:12
-
-
Save assertnotnull/a69bbe1314aeea177059 to your computer and use it in GitHub Desktop.
Simple sum of promises
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
var Q = require('q'); | |
var myarr = [1,2,3,4,5]; | |
Q.resolve(myarr).then(function (results) { | |
return results.reduce(function (prev, current) { | |
console.log(prev, current); | |
return prev + current; | |
}) | |
}).then(function (sum) { | |
console.log(sum); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment