How to do it...

  1. Open your command-line application and navigate to your workspace.
  2. Create a new folder named 3-06-using-promise-all.
  3. Copy or create an index.html that loads and runs a main function from main.js.
  1. Create a main.js file that creates an object named rocket, and calls Promise.all with an empty array as the first argument:
export function main() { 
  console.log('Before promise created'); 
 
  const rocket = {}; 
  Promise.all([]) 
 
  console.log('After promise created'); 
}  
  1. Create a function named addBoosters that creates an object with boosters to an object:
function addBoosters (rocket) { 
  console.log('attaching boosters'); 
  rocket.boosters = [{ 
    count: 2, 
    fuelType: 'solid' 
  }, { 
    count: 1, 
    fuelType: 'liquid' 
  }]; 
  return rocket;  
}   
  1. Create ...

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.