Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
You performed checking on whether the left-end equals to right-end when the iteration is still going (i.e, the loop has not reached its endpoint), resulting in inaccurate comparison. Also, your code will always output
nil
because you had an early exit before returning the result, plus nothing to be returned when there is no match between left-end and right-endI don't think you need .each at all here, and I think you'll find the array arr will accept .count but not .length (length works for strings but not arrays) – does this help?