Created
February 21, 2019 16:12
-
-
Save pieterbeulque/b6f383a0b753ae669ad219282f1ee18f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const ask = async (question) => Promise.resolve('Answer ' + question); | |
const questions = [1, 2, 3]; | |
const answers = await questions.reduce(async (accumulator, nextQuestion) => { | |
const allAnswers = await accumulator; | |
const answer = await ask(nextQuestion); | |
return Promise.resolve([...allAnswers, answer]); | |
}, Promise.resolve([])); | |
console.log(answers); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment