How do I check an array for empty strings?
-
You want to check the array for empty strings.
I wrote it like this, but I feel that it can be more beautiful.
How?
json.reduce((result, current) => result || current[0]==="")
JavaScript Anonymous, Nov 10, 2019 -
json.includes ('');
Lydia Blanchard -
arr.some (item = & gt; item === '')
Or like this:
arr.some (item = & gt;! item)
In the second case, all `null`,` undefined` and everything that converts to `false` will also be foundAnonymous
2 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!