Mad Maxer - Sale. I can not pass the level

// Coins disappear in a few seconds!
// Collect all the gold coins before they disappear.
while(true) {
    var closestGold = null;
    var minGoldDist = Infinity;
    var coinIndex = 0;
    var coins = hero.findItems();
// Find the nearest gold coin.
// Remember: a gold coin has a value of 3.
var coin = hero.findNearestItem();
    if (coins.value == 3 && coin < minGoDist) {
        closetGold = minGoDist;
        if (closestGold) {
// Now get to the nearest gold coin and take it!
hero.moveXY(coin.pos.x, coin.pos.y);
        }
    }
}

Could we have a description of you problem please.

@Unknown is right, but I’m just wondering, I’m not a pro in javascript, but is

a thing? In my python code(and I think in javascript) 9999 would work fine.

1 Like

I did not quite understand what to write in hero.moveXY();

I don´t know why you have the above because If this

Is true and its within your range you don´t need to add a varable thats always going to be true

In answer to your question I believe you have the right code there but I still am wondering what your hero is doing so that you cannot pass, could you please describe what your hero is doing please.

my hero just stands still. so I decided that the matter was hero.moveXY();

I have not gotten to that level so can you take a screen shot

Never mind, I think that I found it

Think about it closestGold is null if there is nothing you can not go to nothing. Let me put another way…
Your code basicly says this(Useing what closestGold stands for)
If nothing(null)
go where nothing is(coin.pos.x, coin.pos.y)

So I think that one of your problems is what you used for

you need something other than null

1 Like

Hint: If coins are there go get them

1 Like