← Back to challenges

Odd One Out

JavaScriptHardarraysvalidation

Instructions

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.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.