Go Fetch! Code Combat level

Can someone explain to me how
</>
// You’ve been caught in a burl trap!
// Send your pet to fetch the health potions!

function goFetch() {
// You can use loops in a handler function.
while(true) {
var potion = hero.findNearestItem();
if(potion) {
// Use pet.fetch() to have your pet fetch a potion:
pet.fetch(item);
}
}
}

// When your pet is summoned, it triggers a “spawn” event.
// This tells your pet to run goFetch() at the start of the level
pet.on(“spawn”, goFetch);
</>

doesn’t work?

var potion = hero.findNearestItem();
pet.fetch(item);
two things this could possibly be. Your hero is finding nearest enemy, so, try having your pet find the nearest item : var potion = pet.findNearestItem();
OR the most likely possibility, would be that you are defining the nearest item in a variable called potion, and then trying to call it by calling the variable item. That does not work. You need to change pet.fetch(ITEM); to - pet.fetch(potion);

def goFetch():
# You can use loops in a handler function.
while True:
#potion = hero.findNearestItem()
potion = hero.findNearest(hero.findItems())
if potion:
# Use pet.fetch() to have your pet fetch a potion:
pet.fetch(potion)
pass

When your pet is summoned, it triggers a “spawn” event.

This tells your pet to run goFetch() at the start of the

Its not working please help!!!