Exercise: Extending Objects



In this exercise, you will use object oriented programming concepts to extend a custom object in JavaScript.


  1. Use repl.it for this exercise, choosing "JavaScript" as the language.
  2. Start with your solution from the last exercise (or copy it from here)
  3. Define a new class called MusicVideo that extends Video. Its constructor should also take in an artist argument.
  4. Instantiate a new MusicVideo object and call the watch() method on it.
  5. Add a method to MusicVideo called rockOut() that uses console.log to output a string like "You rocked out to La Bamba by Ritchie Valens!.
  6. Bonus: Use an array of data and a for loop to instantiate 5 MusicVideo objects.
  7. Bonus: Make an array of video data with both normal videos and music videos, loop through them, and decide on each one whether to make it a Video or MusicVideo object.