I have the following Array of objects:
let objOperacion = [
{
"OPERACION": {
"ID_OP": 1
},
"GEOJSON": [
{
"type": "Feature",
"properties": {
"ID": 40,
"SUPERFICIE": 572.7
},
}
]
},
{
"OPERACION": {
"ID_OP": 2
},
"GEOJSON": [
{
"type": "Feature",
"properties": {
"ID": 41,
"SUPERFICIE": 572.7
},
}
]
},
{
"OPERACION": {
"ID_OP": 1
},
"GEOJSON": [
{
"type": "Feature",
"properties": {
"ID": 42,
"SUPERFICIE": 572.7
},
}
]
}
]
I have created a function that when passing an id as parameter, it takes all the objects that have the same id.
I have done it in the following way:
for (var i = 0; i < objOperacion.length; i++) {
if (id === objOperacion[i].feature.properties.ID) {
objOperacion[i].setStyle(styleWorking);
console.log("SAME ID");
} else {
objOperacion[i].setStyle(style);
console.log("DIFFERENT");
}
}
What I am trying to do is to create another function to catch objects that have the same "ID_OP". But I can't get it.
Array.filter()developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…