Forest Shadow Bug or just me?


#1

I did my code correctly but my hero keeps targeting an ogre instead of a thrower or a munchkin.
This is my code:

// Attack only the small ogres in the forest.
// Collect coins and gems only.
// Don’t leave the forest and don’t eat/drink anything.


`var enemy = hero.findNearestEnemy();`


var item = hero.findNearestItem();

while(true) {
    // Find the nearest enemy.
    // Attack it only if its type is "thrower" or "munchkin".
    if (enemy.type == "thrower" || "munchkin") {
      hero.attack(enemy);
}
}
// Find the nearest item.
// Collect it only if its type is "gem" or "coin".
if (item.type == "gem" || "coin") {
    var pos = item.pos;
    var x = pos.x;
    var y = pos.y;
}

#2

Put these lines inside while-loop:

var enemy = hero.findNearestEnemy();
var item = hero.findNearestItem();

#3

I’m going to do it. Doing codecombat while checking on this discourse


#4

It just ran out of time


#5

There is an requirement with the loops where you need to do something each iteration or it causes an issue.

So the statement:

if (enemy.type == "thrower" || "munchkin") {
  hero.attack(enemy);
}

Should have an else clause that does something like `hero.say(“No enemies available”);


#7

[please, don’t post solutions]