I am trying to learn Javascript specifically the method, "filter()". I want to get an array of names from an array of objects. It just returns the same array of objects passed as an argument. What am I missing?
Update: I confused filter() with map(). I am sorry to waste people's time.
personsObj = {
persons: [{name: "Baig",age: 14},{name: "HenTie", age: 20}]
}
switchButtonHandler = (personsArray) => {
var names = this.personsArray.persons.filter((obj) => obj.name);
console.log(names);
}