Advertisement
Guest User

Untitled

a guest
Mar 25th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. function TwitterUser (name, handle, email, age) {
  12. // SET NAME, HANDLE, EMAIL, AND AGE IN THE BLANK SPACE BELOW (Hint: use "this")
  13. this.name=name;
  14. this.handle=handle;
  15. this.email=email;
  16. this.age=age;
  17.  
  18.  
  19.  
  20.  
  21. // do not edit below, creating empty arrays (lists) for followers and tweets
  22. this.following = [];
  23. this.tweets = [];
  24. }
  25.  
  26. TwitterUser.prototype.updateName = function (newName) {
  27. // Directions: set updateName as this objects name, then console.log new name
  28. this.name=newName;
  29. console.log("newName");
  30.  
  31.  
  32.  
  33.  
  34. };
  35.  
  36. TwitterUser.prototype.updateHandle = function (newHandle) {
  37. // Directions: set newHandle as this objects handle, then console.log new handle
  38. this.handle=newHandle;
  39.  
  40.  
  41.  
  42. };
  43.  
  44. TwitterUser.prototype.updateEmail = function (newEmail) {
  45. // Directions: set newEmail as this objects email, then console.log new email
  46. this.email=newEmail;
  47.  
  48.  
  49. };
  50.  
  51. TwitterUser.prototype.tweet = function (tweetMessage) {
  52. // Directions: add (push) tweetMessage to the "tweets" array, then alert(tweetMessage)
  53.  
  54. this.tweets.push(tweetMessage);
  55.  
  56. };
  57.  
  58. TwitterUser.prototype.followUser = function (anotherTwitterUser) {
  59. // Directions: add (push) tweetMessage to the "following" array
  60. this.following.push(anotherTwitterUser);
  61.  
  62.  
  63. };
  64.  
  65. TwitterUser.prototype.showFollowers = function (anotherTwitterUser) {
  66. // Directions: console.log each individual follower on a new line, by name (Hint: for loop)
  67.  
  68. for(var i=0;i<this.following.length;i++){
  69. console.log(this.following[i].name);
  70. }
  71.  
  72. };
  73.  
  74. TwitterUser.prototype.showTweets = function (anotherTwitterUser) {
  75. // Directions: console.log each individual tweet on a new line, by name (Hint: for loop)
  76.  
  77. for(var i=0;i<this.tweets.length;i++){
  78. console.log(this.tweets[i]);
  79. }
  80.  
  81. };
  82.  
  83.  
  84. var maurice = new TwitterUser("Maurice", "@superMaurice", "maurice@gmail.com", 16);
  85. var maggie = new TwitterUser("Maggie", "@superDuperMaggie", "maggie@gmail.com", 17);
  86. var val = new TwitterUser("val", "@superDuperMaggie", "maggie@gmail.com", 17);
  87.  
  88. maurice.updateName("Maurice S.");
  89. maurice.updateHandle("@superMaurice1000");
  90. maurice.updateEmail("maurice1000@gmail.com");
  91.  
  92. maurice.followUser(maggie);
  93. maurice.followUser(val);
  94. maurice.tweet("@superDuperMaggie cool handle!");
  95. maurice.tweet("fkkgyguykuyyt!");
  96.  
  97. maurice.showFollowers();
  98. maurice.showTweets();
  99. </script>
  100.  
  101.  
  102.  
  103. <script id="jsbin-source-javascript" type="text/javascript">function TwitterUser (name, handle, email, age) {
  104. // SET NAME, HANDLE, EMAIL, AND AGE IN THE BLANK SPACE BELOW (Hint: use "this")
  105. this.name=name;
  106. this.handle=handle;
  107. this.email=email;
  108. this.age=age;
  109.  
  110.  
  111.  
  112.  
  113. // do not edit below, creating empty arrays (lists) for followers and tweets
  114. this.following = [];
  115. this.tweets = [];
  116. }
  117.  
  118. TwitterUser.prototype.updateName = function (newName) {
  119. // Directions: set updateName as this objects name, then console.log new name
  120. this.name=newName;
  121. console.log("newName");
  122.  
  123.  
  124.  
  125.  
  126. };
  127.  
  128. TwitterUser.prototype.updateHandle = function (newHandle) {
  129. // Directions: set newHandle as this objects handle, then console.log new handle
  130. this.handle=newHandle;
  131.  
  132.  
  133.  
  134. };
  135.  
  136. TwitterUser.prototype.updateEmail = function (newEmail) {
  137. // Directions: set newEmail as this objects email, then console.log new email
  138. this.email=newEmail;
  139.  
  140.  
  141. };
  142.  
  143. TwitterUser.prototype.tweet = function (tweetMessage) {
  144. // Directions: add (push) tweetMessage to the "tweets" array, then alert(tweetMessage)
  145.  
  146. this.tweets.push(tweetMessage);
  147.  
  148. };
  149.  
  150. TwitterUser.prototype.followUser = function (anotherTwitterUser) {
  151. // Directions: add (push) tweetMessage to the "following" array
  152. this.following.push(anotherTwitterUser);
  153.  
  154.  
  155. };
  156.  
  157. TwitterUser.prototype.showFollowers = function (anotherTwitterUser) {
  158. // Directions: console.log each individual follower on a new line, by name (Hint: for loop)
  159.  
  160. for(var i=0;i<this.following.length;i++){
  161. console.log(this.following[i].name);
  162. }
  163.  
  164. };
  165.  
  166. TwitterUser.prototype.showTweets = function (anotherTwitterUser) {
  167. // Directions: console.log each individual tweet on a new line, by name (Hint: for loop)
  168.  
  169. for(var i=0;i<this.tweets.length;i++){
  170. console.log(this.tweets[i]);
  171. }
  172.  
  173. };
  174.  
  175.  
  176. var maurice = new TwitterUser("Maurice", "@superMaurice", "maurice@gmail.com", 16);
  177. var maggie = new TwitterUser("Maggie", "@superDuperMaggie", "maggie@gmail.com", 17);
  178. var val = new TwitterUser("val", "@superDuperMaggie", "maggie@gmail.com", 17);
  179.  
  180. maurice.updateName("Maurice S.");
  181. maurice.updateHandle("@superMaurice1000");
  182. maurice.updateEmail("maurice1000@gmail.com");
  183.  
  184. maurice.followUser(maggie);
  185. maurice.followUser(val);
  186. maurice.tweet("@superDuperMaggie cool handle!");
  187. maurice.tweet("fkkgyguykuyyt!");
  188.  
  189. maurice.showFollowers();
  190. maurice.showTweets();</script></body>
  191. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement