Rich Forager Help!

I really can’t figure out what is wrong with this java script code
the third line is apparently wrong I can not figure out what is wrong with this.
it says that it can’t find the pos of null even though I defined it right there. and that isn’t even whats not working it all works until she grab’s all the coins and she won’t pick up the flag!!!
please help.

loop {
        var Item = this.findNearest(this.findItems());
        var coinx = Item.pos.x;
        var coiny = Item.pos.y;
[...deleted the good parts :-) ...]
    }

What if Item doesn’t exist? Then Item is null, and there is no pos of null. (Just like what the error says.)

first of all thanks but I got some help and figured it out anyway :smiley: , second of all what’s with that deleted the good parts thing :hushed: ? I did not write that.

Sorry for the late answer.
You’re post has been edited to prune the unimportant parts (unimportant = not related to the problem).
Only Moderators can do so without your consent. You should have gotten a notification in the speech-bubble in the top right corner.