Currently, I am working on a project involving Javascript and I need to eliminate zero values from an array that looks like this:
0 : Object
color : "#24a7e1",
data : Array[119],
name : "Active
status : 2
1 : Object
color : "#26a727",
data : Array[119],
name : Completed,
status: 4
The number of objects in this array can vary, but my goal is to iterate through each one, access the 'data' attribute, and remove any zero values from it.
I tried handling a specific array with the following code:
for(var i=0; i<filteredValueData[0].data.length;i++ )
{
if(filteredValueData[0].data[i] == 0)
filteredValueData[0].data[i].splice(i,1);
}
However, I encountered the error:
filteredValueData[0].data[i].splice is not a function
At this point, I'm uncertain about what I may be doing incorrectly. The object could contain anywhere between 0 and 5 arrays inside of it.