title: Remove duplicates from arrays using reduce
body: <p>I am trying to remove duplicates from a list of arrays.  The way I was trying to do this is by using reduce to create an empty array that pushes all undefined indexes onto that array.  I am getting errors though that  </p>
  
  <pre><code>if(acc[item]===undefined){
        ^
  TypeError: Cannot read property '1' of undefined
  </code></pre>
  
  <p>my function below:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function noDuplicates(arrays) {
    var arrayed = Array.prototype.slice.call(arguments);
  
    return reduce(arrayed, function(acc, cur) {
      forEach(cur, function(item) {
        if (acc[item] === undefined) {
          acc.push(item);
        }
        return acc;
      });
    }, []);
  }
  
  console.log(noDuplicates([1, 2, 2, 4], [1, 1, 4, 5, 6]));</code></pre>
  </div>
  </div>
  </p>