Exercise: Creating Objects



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


  1. Use repl.it for this exercise, choosing "JavaScript" as the language.
  2. Create the constructor function for a Video object. The function should take in arguments of title (a string), uploader (a string, the person who uploaded it), and seconds (a number, the duration), and it should save them as properties of the object.
  3. Create a method on the Video object called watch(). When that method is called, it should use console.log to output a string like "You watched all 60 seconds of Otters Holding Hands!"
  4. Instantiate a new Video object and call the watch() method on it.
  5. Instantiate another Video object with different constructor arguments.
  6. Bonus: Use an array of data and a for loop to instantiate 5 Video objects.
  7. Bonus: Make the watch method accept amounts of seconds to watch for, and call it with different amounts of seconds.