← Back to challenges

Ones and Zeroes

JavaScriptHardstringsloopsregexvalidation

Instructions

Write a function that returns true if every consecutive sequence of ones is followed by a consecutive sequence of zeroes of the same length.

Examples

sameLength("110011100010") ➞ true

sameLength("101010110") ➞ false

sameLength("111100001100") ➞ true

sameLength("111") ➞ false

Notes

N/A

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