- Open your command-line application and navigate to your workspace.
- Create a new folder named 11-05-create-map-from-data.
- 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;
}
}
- 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')
}
- 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)
}
- Start your Python web server and open the following link in your browser:
http://localhost:8000/.
- 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.