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
@myjinxin2015 version looks slick af, but it is quite slow performance wise. Your ( @hei-yu-fa ) code does not look that good, but is twice as fast. It all comes down to what you are after.
@myjinxin2015 timed at 3870.2 milisec when called for nNumber = 5000
@hei-yu-fa timed at 1972.2 milisec when called for nNumber = 5000
ah yeah the sorting.............................real headache
It's a clever utilization of the comma operator to compress all the stuff into a one-liner. The comma operator just evaluates both its sides and returns the right hand one, so here it allows for assigning to a property of an object but returning the entire object instead of just the property. Also, look at the assignment string: it's not enclosed in apostrophes but backticks, so it's a template literal.
This comment is hidden because it contains spoiler information about the solution
Currently Codewars platform has lots of issues. It's not a problem of this kata. See:
https://github.com/Codewars/codewars.com/issues/893
Wow! That's some hardcore coding!
Still... you solved this challenge in a completely different way, and learned of other approaches. If you learned something in the process, then Achievement Unlocked! ^^
I took around 90 lines of code .. this broke my heart. brute force method to the point of not even being proud lol.
You have taught me I know nothing in JS yet
Yeah, don't worry about it. It takes time to learn all the tricks of the trade ^^
learning and training ;-)