It should be something like that
Keep enemyIndex+=1 out of the if loop. and make your hero attack enemy not enemies. @Deadpool198 already explained how to get rid of the infinite loop.
thankyou i got it i love this so much i am so happy code combat has forums
Mark whichever post helped you solve this problem