Ad
  • Custom User Avatar

    I see your point. I like to push myself to really think about the problem and how I would solve it being it a real app where even these small things can be critical in overall measure.

    Clean code is surely good goal too.

  • Custom User Avatar

    Thank you for your comment.

    A "simple" loop would be hard to read. My goal was readability. But reduce might be a good choice here.

  • Custom User Avatar

    Thanks for your comment. My solutions goal was to be very expressive. Easy to read, understand, maintain.

    Performance was no goal here for me and most time it isn't important, because the code is fast enough anyway. That may be different when developing algorithms or in some performance critical requirements. For sure, it can be much fun to find out the most performant way. ;)

    But I even claim, that writing expressive, clean, readable code is more challenging.

  • Custom User Avatar

    Why to create RegExp everytime? You can just keep it in a closure to save some microseconds :) Also in expression itself it's not necessary to use {1}, it's implicit behavior.

  • Custom User Avatar

    Wow, did not expect someone would do it this way :)