# Help with "cleave" command in level Siege of Stonehold

**URL:** <https://discourse.codecombat.com/t/help-with-cleave-command-in-level-siege-of-stonehold/5514>\
**Category:** Uncategorized\
**Created:** [November 2, 2015, 11:23am UTC](https://discourse.codecombat.com/t/help-with-cleave-command-in-level-siege-of-stonehold/5514 "2015-11-02T11:23:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ballettamaus](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@Ballettamaus](https://discourse.codecombat.com/u/Ballettamaus)\
**Post date:** [November 2, 2015, 11:23am UTC](https://discourse.codecombat.com/t/help-with-cleave-command-in-level-siege-of-stonehold/5514/1 "2015-11-02T11:23:10Z")

</div>

Hey, I got a problem with the level “Siege of Stonehold”, I just can’t make the code " right", and I don’t know what I am supposed to change

```python
 loop {
   var enemy = this.findEnemies();
   var green = this.findFlag("green");

if (green) {
    this.pickUpFlag(flag);
    this.moveXY(19, 69);
    } else {
        this.findNearest(enemy);
        if (this.isReady("cleave")) {
            this.cleave(enemy);
            } else {
                this.attack(enemy);
            }
    }
}

```

There is supposedly an error in Line 15 ( this.cleave(enemy) )… apparently I am told that “ArgumentError is not defined”… I rechecked everything ( that I know) could be wrong and tried since yesterday to make it work… I am really desperate as I really don’t even know, what’s wrong (as I just did everything as in the levels befor) 😕

---

<div class="post-metadata">

**Author:** ![ChronistGilver](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chronistgilver/32/3778_2.png) [@ChronistGilver](https://discourse.codecombat.com/u/ChronistGilver)\
**Post date:** [November 2, 2015, 4:00pm UTC](https://discourse.codecombat.com/t/help-with-cleave-command-in-level-siege-of-stonehold/5514/2 "2015-11-02T16:00:46Z")

</div>

On line 8, your command is `this.findNearest(enemy);`. This doesn’t work. You need to define it as a variable, like `var nearest = this.findNearest(enemy)`.

---

<div class="post-metadata">

**Author:** ![ameen](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ameen/32/3176_2.png) [@ameen](https://discourse.codecombat.com/u/ameen)\
**Post date:** [November 2, 2015, 5:26pm UTC](https://discourse.codecombat.com/t/help-with-cleave-command-in-level-siege-of-stonehold/5514/3 "2015-11-02T17:26:48Z")

</div>

On line 8, your command is this.findNearest(enemy);. This doesn’t work. You need to define it as a variable, like:  
“var nearest = this.findNearest(enemy)” Because in java script you ALWAYS make a variable first then you write a command.

---

<div class="post-metadata">

**Author:** ![Ballettamaus](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@Ballettamaus](https://discourse.codecombat.com/u/Ballettamaus)\
**Post date:** [November 2, 2015, 5:45pm UTC](https://discourse.codecombat.com/t/help-with-cleave-command-in-level-siege-of-stonehold/5514/4 "2015-11-02T17:45:39Z")

</div>

@ChronistGilver and @ameen  
Thank you both so much for your help!!! Now I got through the level 😊

---

<div class="post-metadata">

**Author:** ![ameen](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ameen/32/3176_2.png) [@ameen](https://discourse.codecombat.com/u/ameen)\
**Post date:** [November 2, 2015, 5:47pm UTC](https://discourse.codecombat.com/t/help-with-cleave-command-in-level-siege-of-stonehold/5514/5 "2015-11-02T17:47:04Z")

</div>

No problem if you have any problems just contact me

---

<div class="post-metadata">

**Author:** ![Msakr](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@Msakr](https://discourse.codecombat.com/u/Msakr)\
**Post date:** [November 3, 2015, 2:58pm UTC](https://discourse.codecombat.com/t/help-with-cleave-command-in-level-siege-of-stonehold/5514/6 "2015-11-03T14:58:10Z")

</div>

One other potential problem with your code … what will happen if you drop a flag when there is no enemy? (Maybe not a real problem, but something to watch as a general style point.)
