Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
uniqueAndCount
function uniqueAndCount(list) {
var index = 0,
num = 0;
var result = [];
for (var i = 0; i < list.length; i++) {
if ($.inArray(list[i], result) < 0) {
result.push(list[i]);
while ($.inArray(list[i], list, index) > -1) {
num++;
index = $.inArray(list[i], list, index) + 1;
}
result.push(num);
num = 0;
index = 0;
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.