Help with Cursed Wonderglade [javascript]


#1

I did the code but it keeps giving me an error and I can’t find what is wrong with my code? Please help me identify the mistake

while (true) {
// Find the nearest item.
// Collect it (if it exists) only if its type isn’t “gem”.
var item = hero.findNearest(hero.findItems());
if (item & item.type!=“gem”){
this.moveXY(item.pos.x, item.pos.y);
}
// Find the nearest enemy.
// Attack it if it exists and its type isn’t “burl”.
var nearest = hero.findNearest(hero.findEnemies());
if (nearest & nearest.type!=“burl”){
hero.cast(“drain-life”, nearest);
}

}


#2

&&

[Post must be at least 20 characters]


#3

thank you so much! it worked. I switched from python to java and still learning


#4

mine is python but i still need help i dont know whats wrong


#5

You need to check the existence of an item and enemies.