Skip to content

Instantly share code, notes, and snippets.

@amakhrov
Last active May 21, 2018 16:25
Show Gist options
  • Save amakhrov/c422dcd550593c2f5dc4db07f116735d to your computer and use it in GitHub Desktop.
Save amakhrov/c422dcd550593c2f5dc4db07f116735d to your computer and use it in GitHub Desktop.
Promises
const asyncA = () => Promise.resolve('A');
const asyncB = () => Promise.resolve('B');
const asyncC = (name) => Promise.resolve(`${name}+C`); // e.g. "A+C"
// Please write a function that requests these 3 async functions and combines the results into a single object:
const callAsync = () = { ... }
callAsync().then(result => console.log(result)); // should print: {a: 'A', b: 'B', c: 'A+C'}
// asyncA and asyncB are independent, should be called in parallel
// asyncC takes the "name" argument - should be the resolved result of the asyncA() promise (which means asyncC depends on asyncA)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment