- Open your command-line application and navigate to your workspace.
- Create a new folder named 07-02-assigning-constructor-props.
- Copy or create an index.html that loads and runs a main function from main.js.
- Create a main.js file that creates a new class named Rocket. Add a constructor method that takes a single argument, name, and assigns it to a property of the same name in the body of the method:
// main.js class Rocket { constructor(name) { this.name = name; } }
- Create a main function that creates two instances and logs them out with their property:
// main.js export function main() { const saturnV = new Rocket('Saturn V'); const falconHeavy = new Rocket('Falcon Heavy'); console.log(saturnV.name, saturnV); console.log(falconHeavy.name, ...