What I want to achieve is, look for an object in array
. Always return -1
whatever you want to say that you can not find any match in array
to get your index and then delete that element.
I print the array twice, the first to make sure that the object to be searched is in the array and the second to make sure that it has been deleted, but the object is still there.
I've tried it with pure strings, and it works, but when I search for a complete object I do not ... Any suggestions?
deleteProductFromPurchase(name:string) {
console.log(this.array);
const index: number = this.array.indexOf({idCustomer: 998, idProduct: 664, name: "Montaña", price: 200});
this.testArray.splice(index, 1);
console.log(this.array);
console.log(index);}