I use Array.prototype.find to search for an Object in an array. I would like to use an identifier to find this object. I read about the find method (ES6), but I don't know why my code is wrong.
This is my code:
AddresBook.prototype.getPerson = function (id) {
return this.lisPerson.find(buscarPersona, id);
};
function buscarPersona(element, index, array) {
if (element.id === this.id) {
return element;
} else
return false;
}
source
share