Ad
  • Custom User Avatar

    I'd argue the algorithms in the functions you've listed are pretty obvious (they're all wrappers over a single loop), and that knowing how to use these tools together is more important, but I guess that's just subjective

  • Custom User Avatar

    Wrong. By using the libraries of your respective language, you are:

    1. Making your intentions explicit and steering away from imperitive code. JS is a high-level language; you don't need to write C-like code in it.
    2. Using pre-tested code instead of rewriting it.
    3. Reducing code bloat. This solution does NOT need to be 20 lines; you can write it in as little as a single return statement.

    This is really bad advice to give to beginners. The only time I can see this advice as being sensible is if none of the tools in the library offer suitable abstractions for the problem and you're then putting a circle in a square hole.

  • Custom User Avatar

    Because it's already there at the end of it.

  • Custom User Avatar

    But it is not correct? The example shows that expected answer is not [3, 2, 1, 7, 9, 8, 6, 4, 5], but something else?

    There is this example in description:

    Given [[3, 2, 1], [4, 6, 5], [], [9, 7, 8]], your function should return [1, 2, 3, 4, 5, 6, 7, 8, 9].

    What does your solution return locally for the above input?

  • Custom User Avatar

    Codewars is the machine

  • Custom User Avatar

    What makes you think that your code works on your machine? It seems to miss an essential piece, it seems it would (almost) never return a valid answer. Does it work for you locally for the arrays from the example? Does it return the same answer as the example shows?