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);
}
}
}
please format your code using the </> button and pasting it in the paste code here line.
i did it for you this time
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