How do I check an array for empty strings?

  • 0
    You want to check the array for empty strings.
    I wrote it like this, but I feel that it can be more beautiful.
    json.reduce((result, current) => result || current[0]==="")
    JavaScript Anonymous, Nov 10, 2019

  • 2 Answers
  • 0
    json.includes ('');
    Lydia Blanchard

  • 0
    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 found

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!