Vital Power Codecombat JavaScripet


// This level shows how to define your own functions.
// The code inside a function is not executed immediately. It's saved for later.
// This function has your hero collect the nearest coin.
function pickUpNearestCoin() {
    var items = hero.findItems();
    var nearestCoin = hero.findNearest(items);
    if(nearestCoin) {

// This function has your hero summon a soldier.
function summonSoldier() {
    // If is greater than the cost of the "soldier":
    if ( > hero.costOf("soldier")) 
        // Then summon a "soldier":

// This function commands your soldiers to attack their nearest enemy.
function commandSoldiers() {
    var friends = hero.findFriends();
    for(var i=0; i < friends.length; i++) {
        var enemy = friends[i].findNearestEnemy();
        if(enemy) {
            hero.command(friends[i],"attack", enemy);

while(true) {
    // In your loop, you can "call" the functions defined above.
    // The following line causes the code inside the "pickUpNearestCoin" function to be executed.
    // Call summonSoldier here
    // Call commandSoldiers here

AAAAAAAAAAAAAa i can’t deleted the code


Uhhh are you having a seizure?
You can just press the pencil and edit the code out.

are u ok? @itik u may wanna see a doctor or smthn… unless u dont know how to use forums…

I can’t deleted the code

Its said when i clikc deloerawe(deleted)
you don’t have permission to deleted this topic. if you really want to be deletd, submit a flag to moderator attention togenher with reasoning

Then submit a flag.