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.
This comment is hidden because it contains spoiler information about the solution
I think the problem is that when you use .indexOf on a string, it won't just find a match at the start of it, it might also find a match at the end ('in' in 'berain').
So then, when you try to use substring, it won't divide the word how you would want. Try following those couple lines there yourself with that particular case.
Also, looking at it, I'm afraid the code isn't efficient enough with all the loops, etc. Might wanna reconsider your approach ;) It doesn't seem far off though.
Let me know if this helped.