Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Cs3 javascript level 21 help (SOLVED)

I used very similar code in this level, but it did not work. I had my friend (who already finished this level) send me this code. It works on his computer, but not mine. I am confused.

// The coin field has been seeded with vials of deadly poison.
// Ogres are attacking, while their peons are trying to steal your coins!

while(true) {
    var enemy = hero.findNearestEnemy();
    if(enemy) {
        // Attack the enemy only if the type is NOT equal to "peon".
        if(enemy.type != "peon") {
    var item = hero.findNearestItem();
    if(item.type != "poison") {
        // Gather the item only if the type is NOT equal to "poison".
        hero.moveXY(item.pos.x, item.pos.y);

Welcome to the forum! This is a family-friendly place where coders can share bugs, ask for help on any CodeCombat level (don’t forget to post your code correctly), or just hang out with other coders. But before you proceed, please check out our guidelines: this topic.
Have a great time! :partying_face:


Does it show any error when you run it?

Hi, most of us have never used the scholastic version of CodeCombat (I have) and won’t know which level you are talking about, could you please send the level name? :slight_smile:
Also, the reason it works for him but not for you is because the seed is random every time, so you have to change it.

No, it just no, it just marks an X next to the goal: “collect all coins”

Sorry; the level is named “useful competitors”

Did you read this? :slight_smile:

Yes; how would I change the seed?

Hi @n413673 and welcome to the forum :partying_face: This is a friendly place where you can ask for help on levels, report bugs and chat with other people. Enjoy your time!

I think Moon meant change the code as the seed is random which means the seed will be different each time without you deciding how it will be like


I’ve changed to code many times to no avail. Thanks anyway!

nevermind, the code appears to be working! :slight_smile:


good job! dont forget to click the check box next to any comment