Search
 
SCRIPT & CODE EXAMPLE
 

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];
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: karma get attribute 
Javascript :: code ELIFECYCLE npm ERR! errno 126 
Javascript :: falsy value in javascript 
Javascript :: screeps clear memory of dead screeps 
Javascript :: .localecompare number func 
Javascript :: vite esbuild configuration 
Javascript :: how to input struct into parameter in remix 
Javascript :: createSearchParams 
Javascript :: javascript loop through array of objects es6 
Javascript :: If Presence Shorthand javascript 
Javascript :: convert datetime to milliseconds in javascript 
Javascript :: functional-javascript-workshop solutions 
Javascript :: server starter code in js 
Javascript :: fastest way to sort an array html tags front 
Javascript :: on scroll image blur jquery 
Javascript :: cpprestsdk json 
Javascript :: Flutter retrieve data from Json url 
Javascript :: discord.js v12 to v13 
Javascript :: reverse linklist in javascript 
Javascript :: convert typescript to js online 
Javascript :: js dom after selectors 
Javascript :: jumping on the clouds hackerarnk solution in javascrit 
Javascript :: typeorm cache all queries 
Javascript :: convert json to .env node 
Javascript :: js array random find 
Javascript :: Get client or user ip address in react using axios 
Javascript :: convert fetch in axios 
Javascript :: url is not a constructor javascript 
Javascript :: nodejs express mongodb boilerplate 
Javascript :: define nasty 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =