Hello! I really hate to have to post here - I’d wanted to be able to troubleshoot my code myself - but I’m quite stuck in trying to figure out what I’m doing wrong. I’m in the Backwoods Treasure Challenge level and I can’t seem to get my loop to break. Here’s a bit of the code I’m trying:
while (hero.gold <= 70) {
hero.moveXY(58, 42);
hero.moveXY(61, 54);
hero.moveXY(73, 40);
hero.moveXY(74, 43);
hero.moveXY(74, 62);
hero.moveXY(75, 59);
hero.moveXY(69, 58);
hero.moveXY(66, 64);
hero.moveXY(49, 64);
hero.moveXY(65, 43);
hero.moveXY(62, 42);
hero.moveXY(70, 60);
hero.moveXY(44, 60);
hero.moveXY(46, 52);
hero.moveXY(51, 43);
if (hero.gold >= 70) {
break;
}}
hero.moveXY(25, 17);
… etc.
If you wouldn’t mind, could you tell me what is keeping that from breaking when hero.gold is greater than or equal to 70? When the character reaches 70, she finishes out the while loop and then she goes on to the next part. For her safety, I would like for her to stop and leave the loop as soon as she hits 70 coins. I’ve also tried == and ===, changing where I put the break statement, and changing to just < or >.
Thanks for any help you can provide!