I want to remove elements that occurr more than once and get the unique element. The array always has 3 elements. Lets say i have an array [2,3,2], then I need to get 3 whi
One alternative with filter() function:
var myArray = [1,2,3,2,2,4,3,7,3].sort(); var uniqueValues = myArray.filter(function(item, i, arr) { return (item !== arr[i-1] && item !== arr[i+1]); });
Where uniqueValues = [1,4,7]
uniqueValues