Remove empty string inside array

Hello!
I would like to filter this list that i have in input and remove all the empty string


So far, i’ve tried through the code Node with the function .filter but it return me the same value.

Let me know your opinion!

Thanks for your help!

1 Like

Hello :blush:

I tried to reproduce your usecase as close as possible.

Here is the code block I propose:

const mainJson = $('Set').all()[0].json;
const resultJson = {};

const keys = Object.keys(mainJson);
keys.forEach(key => resultJson[key] = mainJson[key].filter(value => !!value));


return [{"json": resultJson}];

And here is the result:

You can also play with the workflow here:

Don’t hesitate to check input data with console.log !
It helps a lot for debugging this kind of situation :wink:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.