node js reduce then resolve code example
Example: javascript reduce promises
const sum = await [
Promise.resolve(1),
Promise.resolve(1),
Promise.resolve(1)
].reduce(async (previousPromise, itemPromise) => {
const sum = await previousPromise;
const item = await itemPromise;
return sum + item;
}, Promise.resolve(0))
// sum === 3