I want to delete null elements in my array
[ [ null, [ [Array], [Array] ] ] ]
The desired structure is
[ [[Array],[Array]], [[Array],[Array]], [[Array],[Array]] ]
if any of the objects are undefined/null such as :
[ [[Array],[]], [[Array],[Array]], [[Array],[Array]] ]
I wish to remove the full element [[Array],[]]
The 'yes' and 'no' are correctly identifying which elements have the undefined. So I know this code is functioning properly. I tried assigning the empty array as null and then filtering by adding to new array if != null but it did not work.
var filter = Total[0][i];
filter.forEach(e => {
if ((e[0] !== undefined)&&(e[1] !== undefined)) {
console.log('yes');
} else {
console.log('no');
Total[0][i] = null;
}
});
var totalArray = [];
const resultFilter = Total.filter(arr => arr != null);
var Filtereddata = resultFilter.filter(function(element) {
return element !== null;
}
I am unsure how to remove the element or filter into a new array without null.
The null Array is causing problems client side with extra , it would be better to remove the index/element altogether.