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.
I see your point. I like to push myself to really think about the problem and how I would solve it being it a real app where even these small things can be critical in overall measure.
Clean code is surely good goal too.
Thank you for your comment.
A "simple" loop would be hard to read. My goal was readability. But reduce might be a good choice here.
Thanks for your comment. My solutions goal was to be very expressive. Easy to read, understand, maintain.
Performance was no goal here for me and most time it isn't important, because the code is fast enough anyway. That may be different when developing algorithms or in some performance critical requirements. For sure, it can be much fun to find out the most performant way. ;)
But I even claim, that writing expressive, clean, readable code is more challenging.
Why to create RegExp everytime? You can just keep it in a closure to save some microseconds :) Also in expression itself it's not necessary to use
{1}
, it's implicit behavior.Wow, did not expect someone would do it this way :)