Exercise: Constructors



In this exercise, you will use object literals to make cleaner constructors for objects.


  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. Comment out the MusicVideo code, as you'll be working on changing Video first.
  4. Change the Video constructor function to accept a single object literal argument instead of multiple arguments.
  5. Create a new Video object and call watch() on it.
  6. Make the arguments optional by giving them default values if they're not specified.
  7. Bonus: Change the MusicVideo constructor function to also accept a single object literal argument instead of multiple arguments. Test it by calling it at least once.
  8. Super Bonus: make sure that if the object literal is missing some values, that default values are used instead of undefined