Help with "cleave" command in level Siege of Stonehold

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

 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) :confused:

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).

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.

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

No problem if you have any problems just contact me

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.)