Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

CodeCombat - Recruiting queue Help


I need help with this lvl, can someone tell me what l am doing wrong?

// Call peasants one after another.

// Neutral units are detected as enemies.
while(true) {
var neutrals = hero.findEnemies();
if(neutrals) {
} else {
hero.say(“Nobody here”);
// Reassign the neutrals variable using findEnemies()

Line 7: say’s argument message shoulde have type string, but god null. Say what?


Hey! It really helps if you format your code, do this by highlighting your code, and pressing the " < / > " button in the menu while you type!


Well, neutrals is a list, so does not exist. You have to use the first name from that list: use an index.

Further on, you have a hero.findEnemy() statement, which is again incorrect and incomplete. It should be an assignment, like neutrals = hero.findEnemies() (not findEnemy) if it’s needed at all.


ps: oh yes, and next time format your code properly, between three backticks, as described in the FAQ


Sorry, l am new. Don’t know rules, yet.

Ok, Think l get it, but l don’t what to write in hero.say(?).
I did it when it come to names, but not in order, one after another. So, peasants get angry.
Can you tell me what exactly can l do about that.

PS. English is not my native language, I probably made some mistakes. I hope you can understant me well.




And probably replay a few levels, to understand the concept.


I still don’t get why I’m not saying the neutrals name. here is my code.

// Call peasants one after another.
// Neutral units are detected as enemies.
var neutrals = hero.findEnemies();
while (true) {
    if (neutrals.length) {
        // Say the first unit in the neutrals array
    } else {
    // Reassign the neutrals variable using findEnemies()
    var enemies = hero.findEnemies();

I have tried hero.say() many different ways and i still never say anything other than "nobody to bump my gums at"


I try it befor and don’t do anything, just go on else statement.
Thanks anyway, l will try to go back and understend better, or rest some
time of coding.