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.
too easy for 6 kyu
Hi, can you elaborate on what you mean by this is not allowed in real code? Are you meaning I wasn't supposed to do this for the challenge, or in production the original array must be left alone, or something else?
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.
Unfortunately the tests are still broken.
Yep, this solution does not take into account that the killer should have seen all the dead people that day. So the tests are written incorrectly. And the spread operator in this context is just an overcode, you can write dead[0] and the solution will still pass the tests.
I see, if the example in the description would have Johnny as the first value, it would fail.
You're right. The problem is in
includes(...dead)
, which only checks the first name in thedead
list. The current test cases likely miss this bug and should be updated.Because it works, why do you say it shouldn't?
This solution should not work for this problem, I don't understand why it is among the correct solutions.
You are mutating the original array passed as an argument to the function. This is not allowed in real code.
You are mutating the original array passed as an argument to the function. This is not allowed in real code.
You are mutating the original array passed as an argument to the function. This is not allowed in real code.
You are mutating the original array passed as an argument to the function. This is not allowed in real code.
You are mutating the original array passed as an argument to the function. This is not allowed in real code.
You are mutating the original array passed as an argument to the function. This is not allowed in real code.
Loading more items...