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.
While this is clever and concise, I see a lot of comments from people feeling bad about their solutions. Don't beat yourself up. This is O(n log n) complexity which isnt ideal.
using the initial value parameter for the reduce method is an elegant way of handling the empty array scenarios. Something new I've learn't today, thanks.
amazing.
Very Consice !
complexity is bed O(n log n)
did not realize 0 mod 2 is 0. another little lesson, thanks!
damn this gives me depression and anxiety of being totally stupid :(((( I couldn't solve it without chatGPT
"If the input array is empty consider it as: [0] (array with a zero)."
oddOrEven([]) return undefined
When no value is passed to
reduce()
, like ([]
), where the initial value is 0. The reduce returns it's initial value.This skills you guys have in regExp is really exceptional oh. Maybe I should give myself time to learn regExp
This comment is hidden because it contains spoiler information about the solution
Damn, in just one line?
it declares where the accumulator, in this case a is starting at :)
Who didn't solve the kata cannot see the solution but can see the comments.
Thanks! Never knew about that. I'm probably a repeat offender.
Loading more items...