Ad
  • Default User Avatar

    I like this clever solution the most. However, I don't think it is best practice for producion. You will end up looping the string thrice. I know kata here does not considere the performance for evaluation but, for production, in JavaScript, it is not a good idea. After, seeing this, I will use the reduce method and save a loop. But still, it is not my preferred method when performance matters. But, I need to start thinking more on this kind of solution using map, filter, and reduce methods. It's amazing.

  • Default User Avatar

    This solution only takes between 6 and 10 micro seconds to be executed against more than 45 microseconds of the here first rated solution. Indeed, an insignificant difference when you process one string.