One tip for you, is to attack the enemies a bit out of order. I kill the ones in the SW corner, then the ones in the NW and NE corners. Note the mushrooms won’t spawn until everything is killed at the previous part so when you need to heal go back and kill the enemies in the SE corner so that you can heal up.
Also, there are some options to optimize your code. Think about it this way. In each loop, you want to attack as many times as possible. If there are 10 statements executed each iteration of the loop, and only one of them is an attack you are only attacking 10% of the time.
If you can branch the code so that you’re executing less statements per iteration, you will get more DPS. So that you understand what I’m explaining, I’ll use your code as an example:
var enemy = this.findNearestEnemy();
enemy = this.findNearestEnemy();
You see with this minor change, the else only fires and find enemy statement only execute after something dies.
Another tip to consider is the powerup for your weapon. This will do a lot more damage than a regular attack.