Ad
  • Default User Avatar

    I'm not disagreeing with you because I'm still learning JS, but as a programmer that seems wrong to me. Since you can't confirm what type the input will be, wouldn't it be best to check against undefined rather than your method? I mean again, it's clever - but would you really want to use it in production? Is it faster to make sure the input isn't falsy, AND use the code above?

  • Default User Avatar

    Very clever, but is this a best practice? It's not immediately clear what's going on, whereas the other solutions are.

  • Default User Avatar

    Doesn't give enough information on failed test cases, like the array passed in, what the result was, etc.

  • Default User Avatar

    In hindsight, I didn't need to reverse the array, however I started off using .forEach rather than for, and kept the array reversed just... Because.