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);
}
}