error in code, somebody could help me?


#1

Hi, I would like to know why I get an error in my code
while(true) {
var enemy = hero.findNearestEnemy();
if (enemy) {
if (hero.isReady(“throw”)) {
var distance = hero.distanceTo(enemy);
// Only throw if the ogres are more than 15m away.
// Use “if” to compare distance to 15.
if (hero.distanceTo(enemy < 15) {
hero.throw(enemy)
}
// Use “else” to attack if you’re not throwing.
else {
hero.attack(enemy);
}
}
else {
hero.attack(enemy);
}
}
}


#2

please format your code using the </> button and pasting it in the paste code here line.


#3

i did it for you this time


#4

you should change this:

            if (hero.distanceTo(enemy < 15) {

                hero.throw(enemy)

            }

to this

            if (hero.distanceTo(enemy) < 15) {

                hero.throw(enemy)

            }

it is just you have forgotten to put a parenthesis after enemy