Before we can integrate users into our application, let's go ahead and finish building it out. We have three more methods to add and test. The first one is removeUser, which is going to take an argument, the ID of the user you want to remove. This is also going to return the user that was just removed, so if I remove the user with an ID of 3, I want to get rid of it from the list but I do want to return the object.
We'll leave a little note about that, return user that was removed:
removeUser (id) {
//return user that was removed
}
Now the next method that we're going to be filling out is getUser. The getUser method is going to take the exact same arguments as removeUser. We're going to find a user by ID returning the user object, but we're not going to be removing it from the array:
getUser (id) {
}
The final one that we're going to create, as specified up above, is a method called getUserList. This is going to get a list of all the users, just their names by the room name:
getUserList (room){
}
This means that we're going to iterate through the users array looking for all the users whose room matches the room specified. This is going to return an array, something like: 'Mike', 'Jen', 'Caleb', assuming those are the people inside of the room:
getUserList (room) {
['Mike', 'Jen', 'Caleb']
}
Now, notice here that we're not specifying the room or the ID property; we're just returning an array of strings.