Skip to content

Instantly share code, notes, and snippets.

@desinas
Last active January 17, 2020 06:50
Show Gist options
  • Save desinas/e605909fd9fd4cb0394aecea263d91fd to your computer and use it in GitHub Desktop.
Save desinas/e605909fd9fd4cb0394aecea263d91fd to your computer and use it in GitHub Desktop.
Facebook friends Quiz (7-5) of Udacity FEWD
/*
* Programming Quiz: Facebook Friends (7-5)
*
* Create an object called facebookProfile. The object should have 3 properties:
* your name
* the number of friends you have, and
* an array of messages you've posted (as strings)
* The object should also have 4 methods:
* postMessage(message) - adds a new message string to the array
* deleteMessage(index) - removes the message corresponding to the index provided
* addFriend() - increases the friend count by 1
* removeFriend() - decreases the friend count by 1
*/
var facebookProfile = {
name: "Dimitri Kalkas",
friends: 333,
messages: [],
postMessage: function(message) {
return facebookProfile.messages.push(message);
},
deleteMessage: function(index) {
return facebookProfile.messages.splice(index,1);
},
addFriend: function() {
return facebookProfile.friends+= 1;
},
removeFriend: function() {
return facebookProfile.friends-= 1;
}
};
@desinas
Copy link
Author

desinas commented Dec 21, 2017

What Went Well

  • Your code should have a variable facebookProfile
  • The variable facebookProfile should be an object
  • Your facebookProfile object should have a name property
  • Your facebookProfile object should have a friends property
  • Your facebookProfile object should have a messages property
  • Your object's name property should be string
  • Your object's friends property should be a number
  • Your object's messages property should be an array
  • Your facebookProfile object should have a postMessage() method
  • Your facebookProfile object should have a deleteMessage() method
  • Your facebookProfile object should have a addFriend() method
  • Your facebookProfile object should have a removeFriend() method
  • Your object's postMessage() method should add messages to the messages array
  • Your object's deleteMessage() method should remove messages from the messages array
  • Your object's addFriend() method should increment the friends variable
  • Your object's removeFriend() method should decrement the friends variable

Feedback: Your answer passed all our tests! Awesome job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment