The Two Flowers, Cloudrip Mountain, Code Combat

I want to translate my python code to Javascript, because finished in python and I also want to finish in javascript

def summonSoldiers():
    if hero.gold >= hero.costOf("soldier"):
        hero.summon("soldier")



def commandSoldiers():
    for soldier in hero.findByType("soldier"):
        enemy = soldier.findNearestEnemy()
        if enemy:
            hero.command(soldier, "attack", enemy)


def pickUpNearestCoin():
    items = hero.findItems()
    nearestCoin = hero.findNearest(items)
    if nearestCoin:
        hero.move(nearestCoin.pos)


peasant = hero.findByType("peasant")[0]

while True:
    summonSoldiers()
    commandSoldiers()
    pickUpNearestCoin()

Can’t you redo the code from scrach using Java Script?

Yes but I dont know how to write the code in this level in javascript

But how did you arrive to this level? Using Java Script or Phyton? If you did not do it already, I recomand you to play some easier levels with Java Script.

I usually use JavaScript but sometimes use Python so for this level i used python

learn java in web dev

What is web dev? ???

They are subscriber campaigns:

Jeremy, what part about starting from scratch is giving you problems? If you switch to JS and then Restart, you get:
image
The first function can be used as an example for the others. Is this where you get stuck?

i dont know how to define funtions

Ok, as AnseDra recommended, I’d suggest going back and doing some of the earlier levels in JS. I believe this is the first level to explore functions:
https://codecombat.com/play/level/village-rover?

ok thanks @dedreous (20chars)