About cloudrip-commander

Hi I need your help!

var len;
// Each soldier costs 20 gold.
while (this.gold > this.costOf(“soldier”)) {

soldiers = this.findFriends();
soldierIndex = 0;

while(soldierIndex < len(soldiers)){ ←error here??
soldier = soldiers[soldierIndex];
this.command(friend, “move”, {“x”:50, “y”:40});
soldierIndex += 1;
target = {x:48,y:40};
while (this.this.distanceTo(target) > 0){


Mouse over the error sign (yellow triangle, red circle), a floating text box will appear describing the error.

The assignment for soldiers and soldierIndex is in a conditional block.
If the
while (this.gold > this.costOf("soldier"))
condition is not true then soldiers will not be assigned a value

Also, the condition should be this.gold >=
(greater or equal)

I prefer to use a for loop to iterate through an array.
Always state the language you’re working in. (Some are very similar, but have minor differences. Looks like you’re in JScript)

You declare a variable named “len” and then never populate it.
You call that variable as though it were a function later passing it another variable len(soldiers).
All arrays have an element to measure their length. (arrName.length)

And finally, be careful about double “this”