Filter empty strings from array
Given an array with many empty strings
arr = ["a", "", "b", "", "c", "", "d"];
To get rid of the empty strings call filter
and pass the Boolean
method.
arr.filter(Boolean);
> ["a", "b", "c", "d"]
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
Tweet