← Back to challenges

Shared Digits

JavaScriptHardarraysstringsvalidation

Instructions

Create a function that returns true if each pair of adjacent numbers in an array shares at least one digit and false otherwise.

Examples

sharedDigits([33, 53, 6351, 12, 2242, 44]) ➞ true
// 33 and 53 share 3, 53 and 6351 share 3 and 5, etc.

sharedDigits([1, 11, 12, 13, 14, 15, 16]) ➞ true

sharedDigits([33, 44, 55, 66, 77]) ➞ false

sharedDigits([1, 12, 123, 1234, 1235, 6789]) ➞ false

Notes

N/A

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