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.
Most of the names are different, so just for consistency, although either way looks OK.
Minexin, that doesn't answer my question at all. Please read it again. As I brought out, 'add as add' is the same as 'add', why make it longer?
Add and mod functions dont need an alias here, only the other 4 do.
If you still don't understand my question, then see my solution and compare them.
cause the test is expeting some precise names of the fuctions to pass them!
i had the same idea but didn't realize splice whoops lol. good stuff
very nice and readible! I like how this one is written very clear.
could even be a little shorter because shark is repeating.
I have to get into this method soon! GJ
Thanks! 😊
Yeah, reduce itself doesn’t mutate the array, but since I used arr.pop() inside it, the array gets mutated during the process.
You're totally right — wrapping arr as [...arr] before sorting and reducing would make it safer and more idiomatic.
Appreciate the kind words!
You're absolutely right — mutating the original array is not a good practice in production code.
In this case, I went for brevity over purity, since Codewars tests don't reuse the input array.
Thanks for the constructive feedback!
I'll keep it in mind for cleaner and safer code outside of kata environments.
You are mutating the original array passed as an argument to the function. This is not allowed in real code.
Thanks! I find the .reduce method super interesting to use.
N useless method calls. => call it once before the loop.
Just do my code
how about rewrite it from 1 to max safe integer?
I didn't know about the 3rd argument, thanks for this lesson.
take u re time brother!
Loading more items...