I have an object array with the structure in the code below. I have a requirement that if array[i][j].ShipLoc equals the location to be removed that I remove the parent from the array, so I would be removing array[i] from the array which should also remove all of the children. For Example, If I wanted to use ShipLoc = “MALVESEQ” the records that would be removed would be array(1) and array(2). I know I could do nested for loops and loop through the values, but that doesn’t seem like the most optimized solution. Is there a better way to do this or should I be using nested for loops to accomplish this
array = [
[
{
"ShipLOC": "SANCO",
"attributes": [
{
"ucmlLat": "43.881431",
"ucmlLng": "-92.496931",
}
],
"totalLocationProductLength": 184,
"distanceFromKage": 159.39214641507564,
}
],
[
{
"ShipLOC": "MALVESEQ",
"attributes": [
{
"ucmlLat": "40.936476",
"ucmlLng": "-72.653116",
}
],
"totalLocationProductLength": 96,
"distanceFromKage": 1691.1958136706187,
}
],
[
{
"ShipLOC": "SANCO",
"attributes": [
{
"ucmlLat": "43.881431",
"ucmlLng": "-92.496931",
}
],
"totalLocationProductLength": 184,
"distanceFromKage": 159.39214641507564,
},
{
"ShipLOC": "MALVESEQ",
"attributes": [
{
"ucmlLat": "40.936476",
"ucmlLng": "-72.653116",
}
],
"totalLocationProductLength": 96,
"distanceFromKage": 1691.1958136706187,
}
]
]