I'm facing an issue while trying to filter my array of objects using two parameters. Despite having an object in the array with the same values as the parameters, the result is empty.
const item = this.lista.find(i => i.number === rule.number && i.name === rule.name);
Even when attempting to use "filter", I encounter the same problem...
const item = this.lista.filter(i => i.number === rule.number).filter(i =>
i.name === rule.name);
Below is my complete array:
this.lista= [
{number: 0, name: 'jose'},
{number: 2, name: 'maria'},
{number: 3, name: 'martha'},
{number: 4, name: 'ana'},
{number: 4, name: 'petter'},
];
And here is the rule object:
rule = new Rule();
rule.number = 4;
rule.name = 'ana';
Is there a more efficient way to achieve this?