Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    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.