Advertisement
Guest User

Untitled

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