How to do it...

  1. Open your command-line application and navigate to your workspace.
  2. Create a new folder named 11-05-create-map-from-data.
  3. Create a main.js file that defines a new class named Rocket that takes a constructor argument name and assigns it to an instance property:
// main.js 
class Rocket { 
  constructor(name) { 
    this.name = name; 
  } 
   } 
  1. Create an enum of various launch sites:
// main.js 
const LaunchSite = { 
  KENNEDY_SPACE_CENTER: Symbol('Kennedy Space Center'), 
  JUIQUAN: Symbol('Jiuquan Satellite Launch Center'), 
  WHITE_SANDS: Symbol('Jiuquan Satellite Launch Center'), 
  BAIKONUR: Symbol('Baikonur Cosmodrome') 
}  
  1. Create a main function. In that function, create a map with launch site and rocket key value pairs:
// main.js 
export function main() { 
  const rocketSites = [ 
    [ LaunchSite.KENNEDY_SPACE_CENTER, new Rocket('US: Saturn 
V'),], [ LaunchSite.WHITE_SANDS, new Rocket('US: Falcon Heavy') ], [ LaunchSite.BAIKONUR, new Rocket('USSR: Soyuz') ], [ LaunchSite.JUIQUAN, new Rocket('CN: Long March') ] ] const rocketSiteMap = new Map(rocketSites); console.log(rocketSiteMap) }
  1. Start your Python web server and open the following link in your browser:
    http://localhost:8000/.
  2. You should see the following output:
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.60.251