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.
Use spoiler flag when posting code like that, please.
This comment is hidden because it contains spoiler information about the solution
Using
.concat
is misleading because it implies that something is being concatenated.Array.prototype.slice
with no arguments is a much more well-understood practice for duplicating an array thanArray.prototype.concat
with no arguments. While they do the same thing, you need to always look out for future developers looking at your code and trying to make sense of it.Trying to learn from white katas is usually a bad idea because like >90% of the people who're voting on best practice are noobs who have no idea what they're voting on. (And then there are 5% who complains at concise code for not being their familiar Java-like code...)
The best way is to always look 10 solutions from the top and not just 1. This way you can see different ways and practices of doing the same thing.
My guess is that concat() was submitted first, and the Best Practice & Clever upvotes snowballed. Unless somoene can point to performance differences?
Yeah, just wondering why solution with slice() is ranked way lower 'Best Practices'. Any particular reason for that?
a .slice() can be used for duplicating as well.
What's the second argument that takes the function?
It duplicates the input array.
It must be done because
sort
modifies it.Why is necessary the concat()?