steevehook
9/28/2018 - 4:59 PM

Ordered promise resolution

Ordered promise resolution

const arr = [
	new Promise(resolve => { setTimeout(() => { resolve(1)}, 1100)}),
	new Promise(resolve => { setTimeout(() => { resolve(2)}, 100)}),
	new Promise(resolve => { setTimeout(() => { resolve(3)}, 3000)})
];

arr
.reduce((acc, v) => {
    acc.then(accVal => console.log(accVal))
    
	return v;
})
.then(final => console.log(final))