title: how to not return an item on array if it is undefined?
body: <p>I have a function that given an ids i want to return its' corresponding object, this is the code: </p>
  
  <pre><code>var x = {gf:[1,3]};
  var {gf} = x;
  
  var todos = [{id:1,fg:"aaa"},{id:2,fg:"bbb"},{id:3,fg:"ccc"}];
  
  var fg = (gf) =&gt; {
    var f = todos.reduce((todoArray,todo) =&gt; gf.includes(todo.id) ? [...todoArray,todo] : todoArray, []);
    return f;
  }
  console.log(fg);
  </code></pre>
  
  <p>I wanted to return the variable f, but fg is a function? This code works, but I cannot do it because this is a resolve method for graphql:</p>
  
  <pre><code>var f = todos.reduce((todoArray,todo) =&gt; gf.includes(todo.id) ? [...todoArray,todo] : todoArray, []);
  console.log(f); 
  </code></pre>
  
  <p>I tried immediately invoked function but it doesn't work?</p>