{ Asynchronous JavaScript Exercises. }

  • Write a function called inOrder that accepts two callbacks and invokes them in order
var logOne = setTimeout(function(){
}, Math.random() * 1000)

var logTwo = setTimeout(function(){
}, Math.random() * 1000)

inOrder(logOne, logTwo) 

// one
// two

// it should always log those two in order regardless of their timing
  • Refactor the code above to use promises

  • Make an AJAX call to the OMDB API for all the episodes in season one for Game of Thrones. Once you have finished that, loop through the array of imdbIDs and make another AJAX call to get an array of all the plots. Join that array together to form a large string which contains all the plots.

  • Implement a simple version of Promise.all. This function should accept an array of promises and return an array of resolved values. If any of the promises are rejected, the function should catch them.

When you're ready, move on to Introduction to Regular Expressions


Creative Commons License