Howdy and welcome to the forum!
Please be sure to post all of your code properly formatted. You can learn how to do so here: [Essentials] How To Post/Format Your Code Correctly
Also, when posting javascript, add the term ‘javascript’, just after the first three backticks. It will look like this:

// comments will look like comments
hero.attack(enemy); //will look like code