function findOdd(arr) {
var result, num = 0;
//sort()排序
arr = arr.sort();
for (var i = 0; i < arr.length; i++) {
if (arr[i] === arr[i + 1]) {
num++;
} else {
num++;
if (num % 2 != 0) {
result = arr[i];
break; //结束
}
}
}
return result;
}
//测试:
console.log(findOdd([5, 4, 3, 2, 1, 5, 4, 3, 2, 10, 10])) //1
console.log(findOdd([1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1])) //10