title: extract id from array using map with condition javascript
body: <p>There is an array of objects </p>
  
  <pre><code>  const groups = [
      { id: 0, name: "All", selected: false },
      { id: -1, name: "All", selected: true },
      { id: 1, name: "Group1", selected: false },
      { id: 2, name: "Group2", selected: false },
      { id: 3, name: "Group3", selected: false },
      { id: 4, name: "Group4", selected: true }
    ];
  </code></pre>
  
  <p>I want to extract ids from this object with map</p>
  
  <pre><code>groups.map(group =&gt; group.id &gt; 0 &amp;&amp; group.selected ? group.id:null)
  </code></pre>
  
  <p>but the result will be 
  <strong>[null,null,4,null...]</strong>
  actually it should be <strong>[4]</strong></p>
  
  <p>I know I can use another function like <strong>forEach</strong> and <strong>push</strong> or <strong>map</strong> and <strong>filter</strong> but I would solve it with one iteration with map or something else.</p>