# \[Solved\]Need help on Clash of Clones(javascript)

**URL:** <https://discourse.codecombat.com/t/solved-need-help-on-clash-of-clones-javascript/19769>\
**Category:** Level Help\
**Created:** [December 7, 2019, 7:54am UTC](https://discourse.codecombat.com/t/solved-need-help-on-clash-of-clones-javascript/19769 "2019-12-07T07:54:04Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![brooksy125](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/brooksy125/32/9966_2.png) [@brooksy125](https://discourse.codecombat.com/u/brooksy125)\
**Post date:** [December 7, 2019, 4:57pm UTC](https://discourse.codecombat.com/t/solved-need-help-on-clash-of-clones-javascript/19769/2 "2019-12-07T16:57:35Z")

</div>

The problem is you aren’t defeating the enemy “captain” before you die. Since you have the same gear, you will attack each other at the same rate and damage if you don’t use special abilities (rings, emperor’s glove, cleave, bash, shield). This level isn’t as much about simply coding, but developing a strategy that you have to code. If you don’t have a lot of special gear, you can control your hero with flags to control the fight better.

The few suggestions I would make about your current code:

You can combine both the `while (enemyIndex < enemies.length)` into one and just have an `if - else if `chain to find the different enemies. Tip: add a line of code to prevent your hero from attacking “sand-yak”

```python
if (enemy.type == "captain") {} //may not want to directly attack unless using special abilities
else if (enemy.health > strongHealth) {}

```

Make sure you keep your starting variables outside of the loop otherwise you reset them every time and it will skew the results.

Lastly, make sure your `if (strongest)` is outside of the `while (enemyIndex < enemies.length)` loop so you only get the results of the strongest. Oh and typo on the `while (strongest.health >0)`. You want to evaluate the health of the enemy you are fighting not a value that you collected at first.

The post below will give you some other insight for strategy using basic level gear and abilities. While the code is in Python, the concepts carry over.

> [@\[SOLVED\] Need help on Clash Of Clones ASAP](https://discourse.codecombat.com/t/need-help-on-clash-of-clones-asap/19664/12):
>
> What special abilities do you have available to you now? The Chain-lightning from the Emperor’s glove is very effective on this level. Considering you are matched evenly to begin with and then have to fight some extra ogres, the special attacks or spells are the best way you can win this level. If you don’t have any special abilities, try to keep some archers alive and then use flags to run around distracting the enemies to let the archers take them out slowly. Don’t attack unless you have a…

---

_[View the full topic](https://discourse.codecombat.com/t/solved-need-help-on-clash-of-clones-javascript/19769)._
