I have an array res with some nullish values, and I have a function remove that is supposed return an array with nulls and undefined removed, but I can't get it to work on my array. I've seen plenty of answers on this sort of thing, in fact my remove function originated from one of them, but I can't seem to get it to work.
res =
[
{
"1yKKftO0iOyvsacrW1mEr-FylurU8-fwaefewafw": [
"[email protected]",
"[email protected]",
null,
"[email protected]"
]
},
{
"149Lmt-gweagewfrthjregjiojoinONEDOnonao": [
"[email protected]"
]
},
{
"JG043AHF0GJA0EWJIFJO00WIJF-UffFWEAk8QRg4": [
"[email protected]",
"[email protected]"
]
},
{
"1u-Frw5I4agI-FWKE0AFJ0WEJG0JEFDALKFEWA-ns": [
null,
"[email protected]"
]
},
{
"FAWGETAIODIOFAIJDSOIFJWEOFijewaofifejowef": [
"[email protected]"
]
},
{
"fwaejf0JF0EWJIJFFJMojfeoijfewJEJFI0i0fje": [
"[email protected]"
]
},
{
"FJ09Ejf093ejfie0jfeiJFEJF0IWJFEIJFOEJWow": [
"[email protected]"
]
}
]
var remove = function (array) {
var result = [];
array.forEach(function (item) {
if (Array.isArray(item) && item.length!=0) {
// Item is a nested array, go one level deeper recursively
result.push(remove(item));
}
else if (typeof item !== null) {
result.push(item);
}
});
return result;
};
console.log(remove(res));
nulls?