Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Forest Shadow Bug or just me?


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") {
// 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;


Put these lines inside while-loop:

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


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


It just ran out of time


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") {

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


[please, don’t post solutions]