# Agrippa defense

**URL:** <https://discourse.codecombat.com/t/agrippa-defense/3871>\
**Category:** Uncategorized\
**Created:** [May 12, 2015, 3:13pm UTC](https://discourse.codecombat.com/t/agrippa-defense/3871 "2015-05-12T15:13:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LUISA\_FERNANDA\_VACA\_](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/luisa_fernanda_vaca_/32/2764_2.png) [@LUISA\_FERNANDA\_VACA\_](https://discourse.codecombat.com/u/LUISA_FERNANDA_VACA_)\
**Post date:** [May 12, 2015, 3:13pm UTC](https://discourse.codecombat.com/t/agrippa-defense/3871/1 "2015-05-12T15:13:42Z")

</div>

```
I need help in agrippa defense (Javascript)

```

this is mi code and I don’t no detected the problem!  
loop {  
var enemy = this.findNearestEnemy();  
if(enemy) {  
var distance = this.distanceTo(enemy);  
if (distance \< 5 ) {  
this.isReady(“cleave”);  
this.cleave(this.findNearestEnemy());  
}  
else {  
this.attack(enemy);  
}  
}  
}

---

<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:** [May 12, 2015, 3:27pm UTC](https://discourse.codecombat.com/t/agrippa-defense/3871/2 "2015-05-12T15:27:23Z")

</div>

Hello, Luisa, and welcome to the forums. Please read the FAQ on how to properly format your code.

Help us help you, what happens when you run the code? You tell us there is an error, but what is it?

---

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [May 12, 2015, 8:41pm UTC](https://discourse.codecombat.com/t/agrippa-defense/3871/3 "2015-05-12T20:41:45Z")

</div>

Correctly formatted code is especially helpful on this one, but even with out it I do see an error.

you have “this.isReady(“cleave”);” as if it were a command, instead it needs to be part of an “if”:  
if (this.isReady(“cleave”)) {

So that you don’t try to cleave when cleave is not ready. Fix this then if you still have trouble read the FAQ and then post your new code using the correct ```.

---

<div class="post-metadata">

**Author:** ![LUISA\_FERNANDA\_VACA\_](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/luisa_fernanda_vaca_/32/2764_2.png) [@LUISA\_FERNANDA\_VACA\_](https://discourse.codecombat.com/u/LUISA_FERNANDA_VACA_)\
**Post date:** [May 12, 2015, 10:54pm UTC](https://discourse.codecombat.com/t/agrippa-defense/3871/4 "2015-05-12T22:54:48Z")

</div>

thank you so much! 😄
