title: Lodash - Check for empty array in an array of objects using _.some
body: <p>I have an array of objects like this - say testArray. 
  <a href="https://i.stack.imgur.com/Gy7WC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gy7WC.png" alt="enter image description here"></a>
  I need to check that for each object in array, if any of the saveNumbers array is empty, my function should return false. </p>
  
  <p>My function is as follows:</p>
  
  <pre><code>  public checkSaveNumbers(): boolean {
      let result;
      if (this.testArray) {
        result = _.some(this.testArray, member =&gt; !member.saveNumbers.length);
      }
      console.log(result);
    }
  </code></pre>
  
  <p>Here, result is showing true for my above object where we can see that the first element in the array has saveNumbers array empty. I'd expect result to be false in that case. I want to achieve this using Lodash and I'm not sure what is going wrong here. </p>
  
  <p>Update:</p>
  
  <p>As suggested in comments, I changed the code to following: </p>
  
  <pre><code>public checkSaveNumbers(): boolean {
    let result = true;
    if (this.testArray) {
      result = _.every(this.testArray, member =&gt; member.saveNumbers.length &gt; 0); //as soon as the condition is false, result should become false otherwise result will remain true.
      console.log(result);
    }
  }
  </code></pre>
  
  <p>However, with this code, even when my saveNumbers array is non-empty for every member in testArray, I get result as false.</p>