Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width">
- <title>JS Bin</title>
- </head>
- <body>
- <script id="jsbin-javascript">
- function TwitterUser (name, handle, email, age) {
- // SET NAME, HANDLE, EMAIL, AND AGE IN THE BLANK SPACE BELOW (Hint: use "this")
- this.name=name;
- this.handle=handle;
- this.email=email;
- this.age=age;
- // do not edit below, creating empty arrays (lists) for followers and tweets
- this.following = [];
- this.tweets = [];
- }
- TwitterUser.prototype.updateName = function (newName) {
- // Directions: set updateName as this objects name, then console.log new name
- this.name=newName;
- console.log("newName");
- };
- TwitterUser.prototype.updateHandle = function (newHandle) {
- // Directions: set newHandle as this objects handle, then console.log new handle
- this.handle=newHandle;
- };
- TwitterUser.prototype.updateEmail = function (newEmail) {
- // Directions: set newEmail as this objects email, then console.log new email
- this.email=newEmail;
- };
- TwitterUser.prototype.tweet = function (tweetMessage) {
- // Directions: add (push) tweetMessage to the "tweets" array, then alert(tweetMessage)
- this.tweets.push(tweetMessage);
- };
- TwitterUser.prototype.followUser = function (anotherTwitterUser) {
- // Directions: add (push) tweetMessage to the "following" array
- this.following.push(anotherTwitterUser);
- };
- TwitterUser.prototype.showFollowers = function (anotherTwitterUser) {
- // Directions: console.log each individual follower on a new line, by name (Hint: for loop)
- for(var i=0;i<this.following.length;i++){
- console.log(this.following[i].name);
- }
- };
- TwitterUser.prototype.showTweets = function (anotherTwitterUser) {
- // Directions: console.log each individual tweet on a new line, by name (Hint: for loop)
- for(var i=0;i<this.tweets.length;i++){
- console.log(this.tweets[i]);
- }
- };
- var maurice = new TwitterUser("Maurice", "@superMaurice", "maurice@gmail.com", 16);
- var maggie = new TwitterUser("Maggie", "@superDuperMaggie", "maggie@gmail.com", 17);
- var val = new TwitterUser("val", "@superDuperMaggie", "maggie@gmail.com", 17);
- maurice.updateName("Maurice S.");
- maurice.updateHandle("@superMaurice1000");
- maurice.updateEmail("maurice1000@gmail.com");
- maurice.followUser(maggie);
- maurice.followUser(val);
- maurice.tweet("@superDuperMaggie cool handle!");
- maurice.tweet("fkkgyguykuyyt!");
- maurice.showFollowers();
- maurice.showTweets();
- </script>
- <script id="jsbin-source-javascript" type="text/javascript">function TwitterUser (name, handle, email, age) {
- // SET NAME, HANDLE, EMAIL, AND AGE IN THE BLANK SPACE BELOW (Hint: use "this")
- this.name=name;
- this.handle=handle;
- this.email=email;
- this.age=age;
- // do not edit below, creating empty arrays (lists) for followers and tweets
- this.following = [];
- this.tweets = [];
- }
- TwitterUser.prototype.updateName = function (newName) {
- // Directions: set updateName as this objects name, then console.log new name
- this.name=newName;
- console.log("newName");
- };
- TwitterUser.prototype.updateHandle = function (newHandle) {
- // Directions: set newHandle as this objects handle, then console.log new handle
- this.handle=newHandle;
- };
- TwitterUser.prototype.updateEmail = function (newEmail) {
- // Directions: set newEmail as this objects email, then console.log new email
- this.email=newEmail;
- };
- TwitterUser.prototype.tweet = function (tweetMessage) {
- // Directions: add (push) tweetMessage to the "tweets" array, then alert(tweetMessage)
- this.tweets.push(tweetMessage);
- };
- TwitterUser.prototype.followUser = function (anotherTwitterUser) {
- // Directions: add (push) tweetMessage to the "following" array
- this.following.push(anotherTwitterUser);
- };
- TwitterUser.prototype.showFollowers = function (anotherTwitterUser) {
- // Directions: console.log each individual follower on a new line, by name (Hint: for loop)
- for(var i=0;i<this.following.length;i++){
- console.log(this.following[i].name);
- }
- };
- TwitterUser.prototype.showTweets = function (anotherTwitterUser) {
- // Directions: console.log each individual tweet on a new line, by name (Hint: for loop)
- for(var i=0;i<this.tweets.length;i++){
- console.log(this.tweets[i]);
- }
- };
- var maurice = new TwitterUser("Maurice", "@superMaurice", "maurice@gmail.com", 16);
- var maggie = new TwitterUser("Maggie", "@superDuperMaggie", "maggie@gmail.com", 17);
- var val = new TwitterUser("val", "@superDuperMaggie", "maggie@gmail.com", 17);
- maurice.updateName("Maurice S.");
- maurice.updateHandle("@superMaurice1000");
- maurice.updateEmail("maurice1000@gmail.com");
- maurice.followUser(maggie);
- maurice.followUser(val);
- maurice.tweet("@superDuperMaggie cool handle!");
- maurice.tweet("fkkgyguykuyyt!");
- maurice.showFollowers();
- maurice.showTweets();</script></body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement