casprwang/blog

ContainsDuplicate

Closed this issue · 1 comments

After a bit of playing around, I found this more "functional" version of containsDuplicate that takes advantage of array indicies!:

const containsDuplicate = nums => nums.some((num, i) => nums.indexOf(num) != i)

awesome!