problem with removing empty array inside an array

56 Views Asked by At

I've encountered a problem that is wired for me as a beginner javascript coder.

here is my console when I try to log count variable that is an array of arrays:

enter image description here

As I want to remove the empty arrays inside count I added this line of code just above the count log like this:

 count = count.filter(e => e.length);
 console.log(count);

I saw no difference so I tried to log the count in a different way:

count = count.filter(e => e.length);
console.log("count: "+ count);

This time I can see something wired! the count logs with other values! (Iknow these values but I don't know where are they in the first log and why the filter doesn't work)

enter image description here

Please help I'm confused. how I can remove empty arrays on count?

The desired result would be:

enter image description here

0

There are 0 best solutions below