Last active
August 29, 2018 03:17
-
-
Save amakhrov/d3018f110989b070fb58f893d4264bb1 to your computer and use it in GitHub Desktop.
Promises - serial
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
const asyncA = () => Promise.resolve('A'); | |
const asyncC = (prefix) => Promise.resolve(`${prefix}+C`); // e.g. "x+C" | |
// Please write a function that calls these 2 async functions and combines the results into a single object. | |
// asyncC takes the "prefix" argument - should be the resolved result of the asyncA() promise (which means asyncC depends on asyncA). | |
// Basically, first need to call asyncA, then pass the result to asyncC, then combine the both results into the single output object. | |
const callAsync = () => { | |
// your code should be here | |
// ... | |
} | |
callAsync().then(result => console.log(result)); // should print: {a: 'A', c: 'A+C'} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment