Ad
  • Default User Avatar

    I agree with some of your points, but I also see "best practice" more on the concept level. I'm voting best practice for the approach & solution to the problem.

  • Custom User Avatar

    Wow this is incredible and so beautiful. I love this!

  • Custom User Avatar

    camelcase vs snake case is personal preference.

  • Custom User Avatar

    Your solution works and it is simple, clear and easy to read. Not cheating! :)

  • Custom User Avatar

    I agree with the first part but I find the answer's ternary expression much more readable than yours.

  • Custom User Avatar

    I think it's mean to say that it "looks like !@#$". The person is attempting to learn how to code. "Best Practices" and "Clever" are definitely detrimental, however, and this type of solution should NEVER be implemented. It would be very, very slow.

    The fastest and most efficient (i.e. solution that adheres to best practices) would be implementing a simple hashmap lookup table and coupling it with a simple for loop. Feel free to take a look at my solution if you are curious how this is done. It also reads perfectly fine and it is quite clear what is going on and why I chose to solve the problem in the way that I did.

    On that note, using functions that require/involve a callback are also ill-advised due to performance issues. When in doubt, use a simple for loop. It is the fastest, often by quite a large margin. ES6 is not always the best way to go. ES6 can improve readability in some contexts but this comes at a high cost of performance.

  • Custom User Avatar

    I think it's mean to say that it "looks like !@#$". The person is attempting to learn how to code. "Best Practices" and "Clever" are definitely detrimental, however, and this type of solution should NEVER be implemented. It would be very, very slow.

    The fastest and most efficient (i.e. solution that adheres to best practices) would be implementing a simple hashmap lookup table and coupling it with a simple for loop. Feel free to take a look at my solution if you are curious how this is done. It also reads perfectly fine and it is quite clear what is going on and why I chose to solve the problem in the way that I did.

    On that note, using functions that require/involve a callback are also ill-advised due to performance issues. When in doubt, use a simple for loop. It is the fastest, often by quite a large margin. ES6 is not always the best way to go. ES6 can improve readability in some contexts but this comes at a high cost of performance.

  • 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

  • Custom User Avatar

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

  • Custom User Avatar

    lol. You are a perfectionist or haven't seen enough bad code 😄

    btw, I agree with all your arguments.

  • 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