- Open your command-line application and navigate to your workspace.
- Create a new folder named 07-03-defining-methods.
- Copy or create an index.html that loads and runs a main function from main.js.
- Create a main.js with a class named Rocket, which assigns a name property upon construction:
// main.js class Rocket { constructor(name) { this.name = name; } }
- Add a method named takeoff that accepts an option countdown argument. The body of the method should log a message before and after a timeout:
// main.js class Rocket { // ... takeOff(countdown = 1000) { console.log(this.name + ' starting countdown.'); setTimeout(() => { console.log(`Blastoff! ${this.name} has taken off`); }, countdown); } }
- Add a main function that ...