hello guys, im stuck in this level but idk why
while(true) {
var closestGold = null;
var minGoldDist = 9001;
var coinIndex = 0;
var coins = hero.findItems();
// Find the closest coin that is gold.
// Remember that gold coins have a value of 3.
while (coinIndex < coins.length) {
var coin = coins[coinIndex];
if (coin) {
var dist = hero.distanceTo(coin);
if (dist < minGoldDist && coin.value === 3) {
var closestGold = coin;
var minGoldDist = dist;
}
}
coinIndex += 1;
}
}
if(closestGold) {
// Now go to the closest gold coin and get it!
hero.moveXY(closestGold.pos.x, closestGold.pos.y);
}