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.
Aight, thx for the answers. I'll need to read all that quite a few times and let it cook a little.
You have the correct idea about deep ( or maybe shallow, see above ) copies and mutating the array itself.
Documentation can tell you which methods work by mutation and which by returning a new value.
Mutating input values will mutate it at the called site as well as at the call site, which is dangerous in general and will explicitly fail you in this kata.
Look into the difference between "pure code" and "programming by side effect". Impure code is the source of a lot of very preventable bugs.
This comment is hidden because it contains spoiler information about the solution
I don't know Java ( at all. but I had just seen the term "arrayList" in a Java context ), and I don't understand exactly what your problem is. I'd love to help you, but "I don't understand the mechanism" doesn't tell me what you are not understanding.
My bad, I initially thought js builtins arrays was some kind of improved arrayList.
Then, I don't understand the mechanism at all, even after looking at the docs for js arrays or the solutions to this kata.
JavaScript is not Java. JS does not have Lists or ArrayLists. JS Arrays are fully dynamic; there is no size limit at any time ( apart from a general maximum size of ridiculous ).
This kata is so confusing tbh, what I understand is there's a max limit to the initial number of values of an array (normal, it's an arrayList).
But usually arrayLists in js (arrays) resize automatically if the number of values is bigger than the inital max value no ? Even after seeing the doc, I still don't get the mechanism behind it.
Your own test code is irrelevant then; it's testing the wrong thing(s). Try
The error in which a random array of values doesn't return the array without the last value. I'm not sure what's going on under the hood of the codewars random array testing. I can't get any of my own test code to return the error given the same input.
which error ?
This is what I did, and I think I understand that it's better to return a shallow copy that mutate an existing array. However, I don't understand why the error happens. Can someone explain?
I dislike this solution cuz it reminds me how bad I am at math.
I don't think I ever learned that in math class.
me too
Nice use of the properties of the divisions, Euclides would be proud of you guys. Simply and clever.
Loading more items...