Instructor: We have an array of people objects, each one of these objects containing a name and a surname. Our goal is to create a method called Get by Surname where we take a surname as an argument.
We would like to return an array containing only those people who happen to share the same surname as an argument. Here we're calling this method with the surname.dessert visible in the console over here, we have an empty array. This is not something that we want, so we clearly have a bug.
We might start by adding a whole bunch of console log statements into our code. In case if we don't want to do that there's a solution written in Chrome DevTools.
The solution is called logpoints. To use that open up Sources, open up your file, and find the line that you would like to debug. In this case, I'm going to try to build a log of these people that filter operation.
To do that I right-click on the line in question and click on Add Logpoint. Here we can type in our message that we would like to log into the console. I'm going to log in People by Surname in curly brackets because I want to convert it to an object.
After clicking away from this window, you're going to see that this logpoint has been added. If I switch to console and refresh this page, you're going to see that I have managed to log in this People by Surname array which is empty. You can see that the source of this console log is actually the Chrome browser itself.
The bug is probably in this filter function. Let's debug this one as well. Go back to Sources, create another logpoint over here, and I'm going to log in the person object. Then we click away, refresh this page. Now I finally notice the bug.
I've been using person.name where instead I should be using person.surname, so let me do that. Now our function works perfect, and we've managed to debug it without adding any additional console statements into our code.