Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. /* Modify the below to create a new constructor pattern
  2.  
  3. Give Video a static property called `make` - an object - that creates the following API:
  4.  
  5. Video.make
  6. .setSrc('/videos/video.mpeg')
  7. .setTitle('AO Video')
  8. .setLoop(true);
  9.  
  10. which returns a new instance of Video
  11. */
  12.  
  13. function Video(){}
  14. Video.prototype.setSrc = function(src) {
  15. this.src = src;
  16. };
  17. Video.prototype.setTitle = function(title) {
  18. this.title = title;
  19. };
  20. Video.prototype.setLoop = function(loop) {
  21. this.loop = loop;
  22. };
  23. var vid = new Video();
  24. vid.setSrc('/videos/video.mpeg')
  25. vid.setTitle('AO video')
  26. vid.setLoop(true);
  27.  
  28. console.log(vid); // {src: "/videos/video.mpeg", title: "AO video", loop: true}
  29.  
  30. //////
  31.  
  32. function Video() {}
  33. Video.prototype.setSrc = function(src) {
  34. this.src = src;
  35. return this;
  36. };
  37. Video.prototype.setLoop = function(loop) {
  38. this.loop = loop;
  39. return this;
  40. };
  41. Video.prototype.setTitle = function(title) {
  42. this.title = title;
  43. return this;
  44. };
  45. Video.make = (function() {
  46. return new Video();
  47. })();
  48. var vid = Video.make
  49. .setSrc('/videos/video.mpeg')
  50. .setLoop(true)
  51. .setTitle('AO Video');
  52.  
  53. console.log(vid);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement