Usual Day issue


#1

The program will run properly with JavaScript, but I cannot get the last goal of under 8 statements. I tried combining both IF statements, but they will not function properly. I am including the complete code in the hopes someone more skilled could point out what I have missed. Thank you in advance!

while (true) {
var enemy = hero.findNearestEnemy();
var item = hero.findNearestItem();
if (enemy && enemy.type == “munchkin”) {
hero.attack(enemy);
}
if (item && item.type == “coin”) {
var pos = item.pos;
var x = pos.x;
var y = pos.y;
hero.moveXY(x, y);
}
}


#2

Nevermind, I figured it. Took a while, but I realized I.m not seeing all the coding, so when I call a method, its already declared the variables in it. I’m just using it.


#3

just saying, but you should read the FAQ before you post anything. (Your code’s formatting is… cringe)