Promises
Using callbacks for asynchronous development gets the job done – and that is great. However, in many applications, our code needs to use external or asynchronous resources all the time. So, very quickly, we'll get to a situation where inside our callback, there is another asynchronous call, which requires a callback inside the callback, which in turn needs a callback on its own….
It was (and in some cases, it still is) not uncommon to be a dozen levels deep inside the callback hole.
Exercise 10.03: Counting to Five
In this exercise, we'll create a function that, when executed, will output the English words one through five. Each word will appear on the screen 1 second after the last word was displayed:
Note
The code files for this exercise can be found at https://packt.link/zD7TT.
- Create a new file,
counting-1.ts
. - In
counting-1.ts
, add an array with the English number names up to and including five:const numbers = ["One...