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.
This comment is hidden because it contains spoiler information about the solution
Using
_
as a placeholder for "this identifier exists but is not being used" has precedent in other languages and in practice, which makes it preferable IMO to most other choices. It's less about being shorter and more about signalling to the reader that this variable is deliberately being ignored.Of course, JS as a language makes no actual accomodation for this. We can already completely omit unused identifiers in destructuring e.g.
let [,,baz] = ['foo','bar','baz']
, and being able to do that in function declarations as well would make sense, e.g.someArray.filter((,index) => <whatever>)
. Shame we can't.I wouldn't consider using an underscore as a parameter name any simpler than any other naming convention, but it is certainly shorter. If parameter naming length is an important design consideration for you, perhaps using the
arguments
object instead of named parameters would be a better solution.but wouldn't it have been simpler to put
_
to ignore the first parameter?This comment is hidden because it contains spoiler information about the solution
What is the point of having the elem? Why can't you just leave index in the parenthesis ?