- Open your command-line application, and navigate to your workspace.
- Create a new folder named 10-07-get-head-and-tail-from-array.
- 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 a main function with an array of rockets:
// main.js export function main() { const rockets = [ new Rocket('US: Saturn V'), new Rocket('US: Falcon Heavy'), new Rocket('USSR: Soyuz'), new Rocket('CN: Dong Feng'), new Rocket('CN: Long March') ] }
- Use the destructuring syntax and the rest operator to get the head and the tail of the array:
// main.js export function main() { //... ...