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.
Please read how to post code in Discourse, it's the last link I posted, without formatting, the indentation and some other things are lost and it's hard to read. There is no need now, you don't need to post your working code, just for the next time you ask for help.
Read this, please: https://docs.codewars.com/training/troubleshooting/#works-but-no
Your global var keep its value between tests.
Read this too: https://docs.codewars.com/training/troubleshooting/#post-discourse
Usually this is caused because you haven't set up your local environment to match the one on codewars, or you are running tests in a different way. For example, on this kata, there is a reason that your code appears to work locally and it will not work on codewars. On codewars, your code is loaded one time and then it is run over and over again, one test after another. If you test your code locally, you are likely only doing one test at a time. So, locally, try to do this:
I'm willing to bet that you get the correct answer for the first call of your function, but not the second call.