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.
You can just return an object without parenthesis ()
It works until there is NaN or Inf in ls or there is loss of precision.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
😄
This comment is hidden because it contains spoiler information about the solution
thanks a lot! It doesn't allow me switch the flag now :(
That's dangerous. If you skip it and the array has a length of one, you'll try to add the first element with undefined. So it's better practices to add it anyway (only case where you can forget it is when you're absolutely sure there are at least 2 elements.
What you cannot skip, tho: the spoiler flag. ;p
This comment is hidden because it contains spoiler information about the solution
Using map for side effects is generally a yikes, but I think here it's kind of beautiful in a golfy way
The only bad thing about this solution is that it modifies the input. Still very clever and elegant.
Honestly, if you can't read this, I couldn't explain.
If you don't know where to look up
&
, try here.how does it work?
Even though this solution traverses the entire array twice, I still think it is clever because it is so idiomatic. Nice job.
Why not assign
i = 1
and not add1
toi
each loop? Is there a reason?Loading more items...