Count Distinct Elements In Array Javascript Methods