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

Help in level bash em all - Javascript (SOLVED)

Hi, I need some help with my javascript code, the problem is that my hero bashes all the enemies but then does not collect the gems, what is wrong? I do not understand…

I have checked the code more than 10 times and I still do not understand what is wrong, could someone help me? please… :frowning:

Javascript code:

// Be careful with these ogres.
// They are special trained fat-free uber ogres and very strong.
// The keyword is fat-free.
var enemies = hero.findEnemies();
var enemyIndex = 0;

while(enemyIndex < enemies.length) {
    var enemy = enemies[enemyIndex];
    if (enemy) {
        hero.moveXY(40, 33);
        if (enemyIndex >= 4) {
    enemyIndex += 1;

var items = hero.findItems();
var itemIndex = 0;

while(itemIndex > items.length) {
    var item = items[itemIndex];
    if (item) {
        hero.moveXY(item.pos.x, item.pos.y);
    itemIndex += 1;

I have already solved it! the while condition was wrong.

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.