Odd One Out

Published by Mubashir Hassan in

Write a function that returns true if exactly one word in the array differs in length from the rest. Return false in all other cases.

Examples

oddOneOut(["silly", "mom", "let", "the"]) ➞ true

oddOneOut(["swanky", "rhino", "moment"]) ➞ true

oddOneOut(["the", "them", "theme"]) ➞ false

oddOneOut(["very", "to", "an", "some"]) ➞ false

Notes

The length of the array will always have at least three or more words.

Watch a quick demo on how Edabit works.