[SOLVED] Help with Anonymous Bank

So I’m stuck on anonymous bank. Here is my code:

// Find the passwords and get the treasure.

// We intercepted a scout with an encoded message.
var encodedMessage = hero.findNearest(hero.findFriends()).message;
// Here we will store passwords.
var passwordArray = [];
// All real passwords have 5 letters.
var passwordLength = 5;

// Split encodedMessage by using a ";" and save the words in a variable.
var words = encodedMessage.split(";");
// Iterate over all of the words.
for (var word in words) {
    var trimmed = word.trim();
    if (trimmed.length == 5) {
        passwordArray.push(trimmed);
    }
}
    // Trim each word to remove whitespace.
    
    // If the length of the cleaned word is 5:
    
        // Push the cleaned word to passwordArray:
        


// Move to each mark and say the correct password:
var marksPos = [{x: 12, y: 14}, {x: 38, y: 38},
    {x: 42, y: 16}, {x: 54, y: 12}];
for (var i = 0; i < 4; i++) {
    var pos = marksPos[i];
    hero.moveXY(pos.x, pos.y);
    var password = passwordArray[i];
    if (password) {
        hero.say(password);
    } 
    else {
        hero.say("qwerty");
    }
}

I don’t really know what to do.

What problems do you have? The code seems alright…

Try to delete this. Does it work now?

It keeps on saying password is null.

which level is this @twenty-one21, because i might be able to help you?

It’s Anonymous Bank (20 chars)

which map? and maybe send a screenshot?

So not delete that.
I will be right back now I am looking at my code.

Here’s the direct link: https://codecombat.com/play/level/anonymous-bank?codeLanguage=javascript

ah i haven’t done it… but i could try to help though


From the mountain

i’m right behind you! :smile: but how did you get there?

Just a suggestion, @twenty-one21 you can just delete those comment lines since you are not using them…this will get rid of the annoying arrows too.

Ok, thanks (20 chars)

Here is the problem.
Put this instead:

var index = 0;
while (index < words.length){
    var word = words[index];
    index ++;

Does it work now?

can you post your new code @twenty-one21?

hold on, trying the code

var index = 0;
while (index < words.length) {
    var word = words[index];
    if (trimmed.length == 5) {
        passwordArray.push(trimmed);
    }
    index++;
}

MOD edit: I’ve trimmed down the code to just the problem area. It was very close to a solution. (No harm, no foul to the contributors in this topic!)

After that put this

Does it work now?

Yes, it works! Thanks!