Skip to content

Commit 608aea2

Browse files
authored
Update 数组元素重复中找唯一一个不重复的
1 parent 5113f59 commit 608aea2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11

22
6yur 8hao 把这道题搞定
3+
var arr=[2,8,5,0,5,2,6,7,2];
4+
function unique1(arr){
5+
var hash=[];
6+
for (var i = 0; i < arr.length; i++) {
7+
if(hash.indexOf(arr[i])==-1){
8+
hash.push(arr[i]);
9+
}
10+
}
11+
12+
return hash;
13+
}
14+
console.log(unique1(arr))

0 commit comments

Comments
 (0)