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.
OP solved it, closing
Nice one man!
๐
Thank you very much!
Add
console.log(x);
inside your function, make it the first line. See the output panel, the last line you see there is the input that makes your code fail. Once you know which input makes your code fail, you can analyze where in your code you're making a mistake.It's failing that one for instance.
Sorry, but it seems I don't understand what you're talking about. (I'm very new to programming). I debug code by running it in VSC and looking in the terminal to see what different sections of code return. At the end of the story, I run the resulting function, offering it various variables (including from sample tests from the author of kata at CodeWars).
Please explain, what do you mean by "printing the input".
To debug your code. See what the input is, and then you can try the same input in VSC.
Here?
Start by printing the input.
When testing code on CodeWars I get: "TypeError: Cannot read property '0' of undefined". At the same time, VSC does not see errors in my code and testing the function on various strings, I get the correct result.
How could I figure out what the test swears at?
Thank you. But at 1st comment I've just copied the output.
The fixed test your code isn't passing is this:
And the input is not an empty array. The javascript tests never pass an empty array to the function.
I've added a check for the incoming array to see if it was empty. (Like this: "if (...arr.length !== 0)"). And yes: the result of the test before I added this check was the same.
... but its you who added a call with an empty array into your solution?
Tests should not pass in empty arrays. Did you have such problem also before you added the call with empty array into your code?
This comment is hidden because it contains spoiler information about the solution
Loading more items...