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.
This comment is hidden because it contains spoiler information about the solution
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.True ... but - my sum1 = sum and the index comes back on the first example [1,2,3,4,3,2,1] but after being equal never runs the return. Try it!
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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
So yes - I have lots of extra leftover comments and have cleaned it up. One will be for the not equal value but you see that the return b; does not throw produce the passed test for the first array even though the value of i is "reported" as being correct. That is 3.
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.
Why won't my return i give me the value. It is in the if statement. i does equal what I am asking for but it will not return and goes thru the next arr.
You fork it (The button on top right) and then you can run it.
I see it passed the tests but can't get it to work on the console in CodePen.
How do I run it?
Thanks
Approved
Not a kata issue. Closing.
This comment is hidden because it contains spoiler information about the solution
Loading more items...