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);
}
while True:
# Find the nearest item.
# Collect it (if it exists) only if its type isn’t “gem”.
enemy = hero.findNearestItem()
if enemy and enemy.type != "burl":
hero.attack(enemy)
else:
pass
item = hero.findNearestItem()
if item and item.type != "gem":
hero.moveXY(item.pos.x, item.pos.y)
# Find the nearest enemy.
# Attack it if it exists and its type isn’t “burl”.
if enemy:
hero.attack(enemy)
else:
hero.findNearestItem()