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.
...for anyone who don't know JS.
think that's the point
it's what the cool kids to. Makes them look smart and dumb at the same time
In the context of a function that can be expressed as a very short chain of basic methods, I think this syntax is fine and readable.
Obviously you wouldn't cram an extensive and complex function into this kind of one-line solution, but all THIS function needs to do is apply a few methods to a single argument and return it. Perfect use-case for shorthands if there ever was one. If we're worried about who else has to read and work with the code, giving each method its own line would resolve that well enough.
This comment is hidden because it contains spoiler information about the solution
This depends on the reason you're writing code. It's your job/homework, and other people will have to work with your code or review it? Of course, it's a good idea to split stuff into variables (better readability). But there's no reason why you absolutely must use self-explaining constructs (like
Number()
instead of+
, orString()
instead of+""
) because you can still explain everything with comments.On the other hand, if all you do is complete a small task on a competitive programming website, there's no reason to stretch everything into as many lines as possible and write "100% understandable code"; on the contrary, you're doing lots of useless work because "newbies may not understand some interesting language features because they've never encountered any code using those because everybody writes in the same dull pre-ES6 manner".
> Writes a 1-line solution but splits it into 5 lines because reasons
> Talks about how 1-line solutions are evil
How is your code any better?
Wow, what a complete noob with a completely closed attitude up there!
I would disagree :) PS. unary plus before
a
is redundant though.I had difficulty to parse that length invokes after filtering is completed at first glance :)
This comment is hidden because it contains spoiler information about the solution