How to do it...

  1. Open your command-line application and navigate to your workspace.
  2. Create a new folder named 09-07-combine-design-patters-to-fit-new-use-case.
  3. Copy or create an index.html that loads and runs a main function from main.js.
  4. Create a main.js file that defines a new class named Mission. Create a constructor that assigns a name argument to an instance variable. Add a simple print function:
// main.js 
class Mission { 
  constructor (name) { 
    this.name = name; 
  } 
 
  describe () { 
    console.log(` 
The ${this.name} mission will be launched by a ${this.rocket.name} rocket, and 
deliver a ${this.payload.name} to ${this.destination.name}. 
    `); 
  } 
}  
  1. Create a class named Destination. Create a constructor that assigns a name argument to an instance ...

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.