Q:

Write a JavaScript program to chain asynchronous functions

0

Write a JavaScript program to chain asynchronous functions.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const chainAsync = fns => {
  let curr = 0;
  const next = () => fns[curr++](next);
  next();
};
chainAsync([
  next => {
    console.log('0 seconds');
    setTimeout(next, 1000);
  },
  next => {
    console.log('1 second');
  }
]);

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now