How to do it...

  1. Create a new working directory, navigate into it with your command-line application, and start the Python SimpleHTTPServer.
  2. Create a file named rocket.js that exports the name of a rocket, a countdown duration, and a launch function:
export default name = "Saturn V"; 
export const COUNT_DOWN_DURATION = 10; 
 
 
export function launch () { 
  console.log(`Launching in ${COUNT_DOWN_DURATION}`); 
  launchSequence(); 
} 
 
function launchSequence () { 
  let currCount = COUNT_DOWN_DURATION; 
 
  const countDownInterval = setInterval(function () { 
    currCount--; 
 
    if (0 < currCount) { 
      console.log(currCount); 
    } else { 
      console.log('LIFTOFF!!! '); clearInterval(countDownInterval); ...

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.