Created
May 25, 2015 01:20
-
-
Save waystilos/e6fff9974fe53f7eddc4 to your computer and use it in GitHub Desktop.
Find duplicates in array in JS
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
Array.prototype.numberOfOccurrences = function (a) { | |
var count = 0; | |
this.map(function (x) { | |
if (x === a) { | |
count++; | |
} else { | |
return false; | |
} | |
}); | |
return count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment