Mad Maxer - Sale. I can not pass the level


#1
// 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);
        }
    }
}

#2

Could we have a description of you problem please.


#3

@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.


#4

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


#5

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


#6

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.


#7

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


#8

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


#9

Never mind, I think that I found it


#10

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


#11

Hint: If coins are there go get them