# \[SOLVED\] Zoo keeper help?

**URL:** <https://discourse.codecombat.com/t/solved-zoo-keeper-help/19669>\
**Category:** Level Help\
**Created:** [November 19, 2019, 9:03am UTC](https://discourse.codecombat.com/t/solved-zoo-keeper-help/19669 "2019-11-19T09:03:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mondays](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/mondays/32/11029_2.png) [@mondays](https://discourse.codecombat.com/u/mondays)\
**Post date:** [November 19, 2019, 9:03am UTC](https://discourse.codecombat.com/t/solved-zoo-keeper-help/19669/1 "2019-11-19T09:03:57Z")

</div>

my code is supposed to get my hero to gather gold, summon soldiers, send them to some points and then they are supposed to defend a box. over all it works, but the issue is that they only go so far. they dont make it to their points i told them to go too. thank you in advance

---

<div class="post-metadata">

**Author:** ![mondays](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/mondays/32/11029_2.png) [@mondays](https://discourse.codecombat.com/u/mondays)\
**Post date:** [November 19, 2019, 9:04am UTC](https://discourse.codecombat.com/t/solved-zoo-keeper-help/19669/2 "2019-11-19T09:04:44Z")

</div>

this is also in JavaScript

---

<div class="post-metadata">

**Author:** ![Thatguy\_youknow0](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/thatguy_youknow0/32/11040_2.png) [@Thatguy\_youknow0](https://discourse.codecombat.com/u/Thatguy_youknow0)\
**Post date:** [November 19, 2019, 7:47pm UTC](https://discourse.codecombat.com/t/solved-zoo-keeper-help/19669/3 "2019-11-19T19:47:12Z")

</div>

In order for us to help, you must format your code properly! you can do this by pressing the “\</\>” button or by typing in this formation  
 ![19%20AM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/5/50cfe68127891e156cfe892e5c86a08be9184d61.png)

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [November 20, 2019, 7:05pm UTC](https://discourse.codecombat.com/t/solved-zoo-keeper-help/19669/4 "2019-11-20T19:05:20Z")

</div>

Make sure you read the topic properly before offering help. As you will be able to see if you look, this topic is solved, with the tick, and also has [SOLVED] in the title.  
Thanks  
Danny

---

<div class="post-metadata">

**Author:** ![Thatguy\_youknow0](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/thatguy_youknow0/32/11040_2.png) [@Thatguy\_youknow0](https://discourse.codecombat.com/u/Thatguy_youknow0)\
**Post date:** [November 20, 2019, 8:08pm UTC](https://discourse.codecombat.com/t/solved-zoo-keeper-help/19669/5 "2019-11-20T20:08:20Z")

</div>

Oopsy doopy daisy  
sorry

---

<div class="post-metadata">

**Author:** ![gnarlyMarley](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/gnarlymarley/32/34823_2.png) [@gnarlyMarley](https://discourse.codecombat.com/u/gnarlyMarley)\
**Post date:** [May 26, 2023, 3:38pm UTC](https://discourse.codecombat.com/t/solved-zoo-keeper-help/19669/6 "2023-05-26T15:38:34Z")

</div>

my hero is not collecting any coins, so I can’t summon any soldiers. here is my code.

```python
// Protect the cage.
// Put a soldier at each X.
var points = [];
points[0] = {x: 33, y: 42};
points[1] = {x: 47, y: 42};
points[2] = {x: 33, y: 26};
points[3] = {x: 47, y: 26};

// 1. Collect 80 gold.
while(hero.gold >= 80) {
    while(true) {
       let item = hero.findNearestItem();
       if (item) {
            hero.moveXY(item.pos.x, item.pos.y);    
            }
    }
       }
// 2. Build 4 soldiers.
for (let i=0; i < 4; i++) {
    hero.summon("soldier");
}

// 3. Send your soldiers into position.
while(true) {
    var friends = hero.findFriends();
    for(var j=0; j < friends.length; j++) {
        var point = points[j];
        var friend = friends[j];
        var enemy = friend.findNearestEnemy();
        if(enemy && enemy.team == "ogres" && friend.distanceTo(enemy) < 5) {
            // Command friend to attack.
            hero.command(friend, "attack", enemy);
        } else {
            // Command friend to move to point.
            hero.command(friend, "move", point);
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![gnarlyMarley](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/gnarlymarley/32/34823_2.png) [@gnarlyMarley](https://discourse.codecombat.com/u/gnarlyMarley)\
**Post date:** [May 26, 2023, 3:51pm UTC](https://discourse.codecombat.com/t/solved-zoo-keeper-help/19669/7 "2023-05-26T15:51:52Z")

</div>

> [@gnarlyMarley](#):
>
> `o.gold >= 80`

Figured it out! 😀

Changed ‘while(hero.gold \>= 80)’ to ‘while(hero.gold \< 80)’.
