# \[SOLVED\] Endangered Burl, Javascript

**URL:** <https://discourse.codecombat.com/t/solved-endangered-burl-javascript/35213>\
**Category:** Level Help\
**Created:** [March 27, 2023, 5:30am UTC](https://discourse.codecombat.com/t/solved-endangered-burl-javascript/35213 "2023-03-27T05:30:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NotCodeExpect](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/notcodeexpect/32/33876_2.png) [@NotCodeExpect](https://discourse.codecombat.com/u/NotCodeExpect)\
**Post date:** [March 27, 2023, 5:30am UTC](https://discourse.codecombat.com/t/solved-endangered-burl-javascript/35213/1 "2023-03-27T05:30:37Z")

</div>

My level is in the third world and its level 12.  
The error is that as soon as the “ogre” comes the hero does not move and he/she would die.

```python
// Only attack enemies of type "munchkin" and "thrower".
// Don't attack a "burl". Run away from an "ogre"!
while(true) {
    var enemy = hero.findNearestEnemy();
    
    // Remember: don't attack type "burl"!
    if (enemy.type == "burl") {
        hero.say("I'm not attacking that Burl!");
    }
    
    // The "type" property tells you what kind of creature it is.
    if (enemy.type == "munchkin") {
        hero.attack(enemy);
    }
    
    // Use "if" to attack a "thrower".
    if (enemy.type == "thrower") {
        hero.attack(enemy) ;
    }
    }
    // If it's an "ogre", use moveXY to run away to the village gate!
    if (enemy.type == "ogre") {
         hero.moveXY(22, 47) ;
   }

```

---

<div class="post-metadata">

**Author:** ![moonwatcher348](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/moonwatcher348/32/24126_2.png) [@moonwatcher348](https://discourse.codecombat.com/u/moonwatcher348)\
**Post date:** [March 27, 2023, 5:48am UTC](https://discourse.codecombat.com/t/solved-endangered-burl-javascript/35213/2 "2023-03-27T05:48:33Z")

</div>

your `if` is outside the while loop

---

<div class="post-metadata">

**Author:** ![NotCodeExpect](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/notcodeexpect/32/33876_2.png) [@NotCodeExpect](https://discourse.codecombat.com/u/NotCodeExpect)\
**Post date:** [March 27, 2023, 7:30am UTC](https://discourse.codecombat.com/t/solved-endangered-burl-javascript/35213/3 "2023-03-27T07:30:50Z")

</div>

ah teehee thats my bad, thank you

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a9445509d1a758c41b5ddcddc8c8e20a5dedb67f.png) [@system](https://discourse.codecombat.com/u/system)\
**Post date:** [March 27, 2023, 7:31pm UTC](https://discourse.codecombat.com/t/solved-endangered-burl-javascript/35213/4 "2023-03-27T19:31:01Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
