I have an array of objects that fills randomly
var lproducts = [
{
"nombre":"Agua",
"descripcion":"Agua purificada",
"precio": 10.5
},
{
"nombre":"leche",
"descripcion":"leche entera",
"precio": 20
},
{
"nombre":"Manzana",
"descripcion":"Manzana Roja",
"precio": 5
},
{
"nombre":"Galletas",
"descripcion":"Galletas Chocolate",
"precio": 10
}
]
I don't know when an object is added to the array, so I don't know its index, and I want to remove the object whose name property is "Apple". I know that with lproducts.splice(2, 1)
I can remove an object from the array, where the number 2 is the index of the item I want to remove.
What I need to know is the index of the object named apple so I can remove it.