How to do it...

  1. Open your command-line application and navigate to your workspace.
  2. Create a new folder named 04-03-async-function-Promise-chain.
  3. Copy or create an index.html that loads and runs a main function from main.js.
  1. Create an async function, getRandomNumber, that returns a random number:
async function getRandomNumber() { 
  console.log('Getting random number.'); 
  return Math.random(); 
} 
  1. Create an async function, determinReadyToLaunch, that returns true if its first argument is greater than 0.5:
async function deteremineReadyToLaunch(percentage) { 
  console.log('Determining Ready to launch.'); 
  return Math.random() > 0.5; 
}  
  1. Create a third async function, reportResults, that logs out different results if its first argument is true ...

Get ECMAScript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.