More efficient way to execute this javascript code

I put together something for my work but I’ve realized that it may be rather hacky. I’ve got a bunch of instances of the same function (with different arguments) sequenced in a while loop that return 1 or 0 depending on a number of conditions, and if the function returns 1, I break out of the loop, like so:

while (!condition) {
   if (this_function(arg0, arg1) > 0) break;
   if (this_function(arg2, arg3) > 0) break;
   if (this_function(arg4, arg5) > 0) break;
   if (this_function(arg6, arg7) > 0) break;
   if (this_function(arg8, arg9) > 0) break;
   if (this_function(arg10, arg11) > 0) break;
   break;
}

Basically, I want the code to continue executing until one of those functions returns 1, and if none of them do, then to stop completely. There surely is a better/cleaner way to do this, I just can’t seem to rack my brain around how. I am just completely overthinking this? Guard clauses perhaps? If anybody has any suggestions, please let me know.

54 thoughts on “More efficient way to execute this javascript code”

  1. Pingback: sildenafil cost uk
  2. Pingback: viagra amazon
  3. Pingback: walmart viagra
  4. Pingback: levitra 10 mg
  5. Pingback: otc generic cialis
  6. Pingback: doxycycline
  7. Pingback: xenical medication
  8. Pingback: generic clomid 50
  9. Pingback: nolvadex acne
  10. Pingback: naltrexone oral
  11. Pingback: cialis 300mg
  12. Pingback: tadalafil otc

Leave a Comment