30 seconds of code

  Back to Home

filterNonUnique

arraybeginner

Filters out the non-unique values in an array.

Use Array.prototype.filter() for an array containing only the unique values.

const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));