Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

return array odd or even outlier

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];
    }
}
Source by www.encodedna.com #
 
PREVIOUS NEXT
Tagged: #return #array #odd #outlier
ADD COMMENT
Topic
Name
8+2 =