← Back to challenges

Outlier Number

JavaScriptHardarraysnumbersmath

Instructions

Given an array of either entirely odd integers or entirely even integers except for a single Outlier Number, create a function to return this number.

Examples

outlierNumber([2, 3, 4]) ➞ 3
// 2 and 4 are even numbers.
// 3 is an outlier number.

outlierNumber([1, 2, 3]) ➞ 2

outlierNumber([4, 1, 3, 5, 9]) ➞ 4

Notes

Array size will always be >= 3.

javascript
Loading editor…
⌘ ↡ to run
Walks through the solution with reasoning and edge cases.
Next: Just Another Sum Problem But... 😰😱 β†’