Created
September 14, 2013 08:08
-
-
Save callblueday/6559848 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cutRedundant(arr){ | |
for(var i=0;i<arr.length;i++) | |
for(var j=i+1;j<arr.length;j++) | |
if(arr[i]===arr[j]){arr.splice(j,1);j--;} | |
return arr.sort(function(a,b){return a-b}); | |
} | |
调用方法: | |
a=[1,2,2,3,4,5,5]; | |
console.log(cutRedundant(a)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment