re: Daily Challenge #35 - Find the Outlier VIEW POST

FULL DISCUSSION
 

Not elegant, but it'll do the job.

const findOutlier = (arr) => {
 const firstPass = arr.filter(el => el % 2 === 0)
 const secondPass = arr.filter(el => el % 2 !== 0)

 if(firstPass.length === 1) {
   return firstPass[0]
 }
 return secondPass[0]
}
code of conduct - report abuse