Last active
January 17, 2020 06:50
-
-
Save desinas/e605909fd9fd4cb0394aecea263d91fd to your computer and use it in GitHub Desktop.
Facebook friends Quiz (7-5) of Udacity FEWD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What Went Well
Feedback: Your answer passed all our tests! Awesome job!