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.
@JohanWiltink not sure how that is reinventing? Array.prototype.filter accepts a callback and filters on truthy... so . this isn't reinventing, but rather using as intended. Unless I'm looking at it wrong??
The main point of the reply however was that you shouldn't reduce the dataset more than needed. It can be done once rather than 5 times.
As the functional people goes:
fold
over everything! ;-)"you could do" ?
Reinventing
[].filter
is not a Best Practice. Using appropriate native methods is.The direction here is good, but it breaks down quickly as your array grows. Also you could do array.filter which might be more clear . Ex: '1st grade': array.filter(x=> x===6).length,
OH S***! That means I did mine wrong xD
Yea. I would have done this much different, but like ZoZo said, debug rather than re-write.
Actually the initial task of this kata was to "debug" provided code, not to re-write it.
; ) )
You can use the reduce chain method on the array of digits to make this cleaner.