I need help deleting any null elements from my array
[ [ null, [ [Array], [Array] ] ] ]
I am looking to restructure it as
[ [[Array],[Array]], [[Array],[Array]], [[Array],[Array]] ]
If there are any undefined/null objects like :
[ [[Array],[]], [[Array],[Array]], [[Array],[Array]] ]
I want to eliminate the entire element [[Array],[]]
The 'yes' and 'no' messages indicate which elements have the undefined value. However, I have attempted filtering out by checking for null values but without success.
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 uncertain about how to effectively remove the element or filter them into a new array removing any null entries. The presence of null Arrays is causing formatting issues client-side with extra commas, hence it would be preferable to completely remove those indices/elements.