Ad
  • Custom User Avatar

    that function thing is making it look so hard.

  • Custom User Avatar

    Full on codeWARS down here, this solution looks very clean in my opinion. I'm five years late to the battle 💀, wha happened?

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Obviously you wouldn't cram an extensive and complex function into this kind of one-line solution

    I'd like to believe it's true.

  • Custom User Avatar

    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.

  • Custom User Avatar

    Semantic reasons, splits into named variables for readability

    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 +, or String() 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".

  • Custom User Avatar

    > 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?

  • Custom User Avatar

    Please learn how to write readable code w/o one liners hacks and stop talking about closed attitude when you have one yourself.
    I know JS but it doesn't matter, this code still looks like a mess.

  • Custom User Avatar

    Wow, what a complete noob with a completely closed attitude up there!

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    unreadable and confusing syntax, worst practice

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution