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.
Hmm, I did try your code above and only tested the 1st sample test, and it pass!
Try the RESET button, but don't forget to copy your solution code first.
Ah, so it wasn't about return values....
The test server gives you the error:
When slicing an array, you might end up with an empty array, and your
reduce
didn't have an initial value to handle this situation (reducing emptiness?). That's why the tests stop/crash and not because your return value.That code only returns the result if certain conditions are met. What if the condition never met? Read the description again what the kata expect for those conditions.
You seem to suggest that a return statement isn't doing what it's supposed to. That won't be the case. Instead it would be something such as not having executed that return statement.
It may be helpful to keep your code consistently formatted even while writing it. It may also help to only run a single test case while you're debugging so that there's no mixup. Isolating what you want to look at and making sure everything's consistent will make it easier to make correct observations of what is happening.
You fork it (The button on top right) and then you can run it.