• @user94507, including !foundMy in both while-loop conditions leaves for sure the loops at the moment the very first match is found... no need for the breaks, even though they work... --- because I cannot find the tool/context that produces this error... are you using some preprocessor/xcompiler/transpiler etc? Your code - even though logically broken - is JS syntactically absolute correct...

    @Gordon, neat, it's like a find all, where @user94507 was looking for a find first. With the built-in Array.filter() I'm sure that with the expected array sizes it's still orders faster, and has the additional benefit of saving Espruino variables (code space in RAM).

  • @allObjects ah ya! i have overseen this in your suggestion! Brilliant! The way around beak is perfect. Thank you.

    @Gordon I have tried using the function Array.filter() replacing the inner loop. This works although I must pass a parameter to this function and so the Web Ide warns me "don't use a function within a loop".
    By the way Array.find() is not implemented yet which would have been my favorite choice.

About

Avatar for allObjects @allObjects started