Last active
January 31, 2017 09:57
-
-
Save karlpokus/dc6135b54abb53b06fcd to your computer and use it in GitHub Desktop.
Unique items in array. Return count or items.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// data is an array | |
function unique(data) { | |
return data.reduce(function(base, item){ | |
if (base.indexOf(item) < 0 ) { | |
base.push(item); | |
} | |
return base | |
}, []) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment