- Open your command line application and navigate to your workspace.
- Create a new folder named 08-04-checking-with-instanceof.
- Copy or create an index.html that loads and runs a main function from main.js.
- Create two objects rocketMap and inactiveRocketMap:
// main.js let rocketMap = {}; let inactiveRocketMap = {};
- Define a new class named Rocket. Add a constructor. Use the name to assign the instance to the rocketMap and define a simple print method:
// main.js class Rocket { constructor(name) { this.name = name; rocketMap[name] = this; } print() { console.log(this.name + ' is a rocket'); } }
- Add a static find method that retrieves an instance from the rocketMap:
// main.js class Rocket { static find (name) { return ...