rmurphey / js-assessment-answers

125 stars 84 forks source link

Solution with Arrays only #113

Open Satjr opened 6 years ago

Satjr commented 6 years ago

I thought it would be better not to use Objects to answer this since this is an exercice about Arrays.

zeckdude commented 6 years ago

This works too:

   var seen = [];
    var dupes = [];

    arr.forEach(function(value) {
      if (seen.includes(value) && !dupes.includes(value)){
        dupes.push(value);
      }
      seen.push(value);
    });

    return dupes;