Skip to content

Instantly share code, notes, and snippets.

@4skinSkywalker
Created April 16, 2019 17:26
Show Gist options
  • Select an option

  • Save 4skinSkywalker/e5f5984d343467fc2684017f07722280 to your computer and use it in GitHub Desktop.

Select an option

Save 4skinSkywalker/e5f5984d343467fc2684017f07722280 to your computer and use it in GitHub Desktop.
function countUnique(iterable) {
if (iterable.length < 1)
return 0
let i = 0
let j = 1
let count = 1
for (; j < iterable.length; j++) {
if (iterable[i] !== iterable[j]) {
count++
i = j
}
}
return count
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment