Ad
  • Custom User Avatar

    "Mine tries to bail out as early as possible from the 1st loop itself."

    ...nope. 'return', in both .map() and .filter() just return from the current iteration; the loop still continues.

    Use a for() loop and 'break' to exit early.