Skip to content

Instantly share code, notes, and snippets.

@amakhrov
Last active August 29, 2018 03:17
Show Gist options
  • Save amakhrov/d3018f110989b070fb58f893d4264bb1 to your computer and use it in GitHub Desktop.
Save amakhrov/d3018f110989b070fb58f893d4264bb1 to your computer and use it in GitHub Desktop.
Promises - serial
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