📜  返回数组奇数或偶数异常值 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:31.604000             🧑  作者: Mango

代码示例1
function findOutlier(integers) {
    var evens = integers.filter(number => number % 2 == 0);
    var odds = integers.filter(number => number % 2 != 0);
    if (evens.length === 1) {
        return evens[0];
    } else if (odds.length === 1) {
        return odds[0];
    }
}