Ad
  • Custom User Avatar

    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.

  • Custom User Avatar

    Ah, so it wasn't about return values....

    The test server gives you the error:

    Reduce of empty array with no initial value

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    You fork it (The button on top right) and then you can run it.