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.
Does this work?
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.
Oh!The reduce() can be used like this...
So clever!
WTF?
Amazing!
Compare with my solution.hahaha!
How it works?
Currently Codewars platform has lots of issues. It's not a problem of this kata. See:
https://github.com/Codewars/codewars.com/issues/893
Fuck kata,it's difficult.And when I have solved this kata and pass the tests,there is no submit button.OMG!
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
Loading more items...