Skip to content

Instantly share code, notes, and snippets.

@yeco
Created March 11, 2010 17:15
Show Gist options
  • Select an option

  • Save yeco/329368 to your computer and use it in GitHub Desktop.

Select an option

Save yeco/329368 to your computer and use it in GitHub Desktop.
function RemoveDuplicates(arr)
{
//get sorted array as input and returns the same array without duplicates.
var result=new Array();
var lastValue="";
for (var i=0; i<arr.length; i++)
{
var curValue=arr[i];
if (curValue != lastValue)
{
result[result.length] = curValue;
}
lastValue=curValue;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment