Code is never finished (infinite loop with best glasses, but works with simpler glasses)

Im doing Backwoods Treasure 8 in Javascript, and at this point i guess my code is not efficient anymore,
could someone help me? I dont know if I can post the code, as its against the forum guidelines

Heelp!

Perhaps you can try filtering out elements in your coin array based on distance. This will result in less coins that you need to operate on.

# for each element in your coins array
    # if your hero's distance to the coin > maxDistance
        # then remove the coin from the coins array