Drop the flag, Need help


#1
loop {
    flag = this.findFlag();
    if (Flag)
      
        flagpos = flag.pos;
        flagX = flagpos.x;
        flagY = flagpos.y;
        this.buildXY('fire-trap',flagX,flagY);
        this.pickUpFlag(flag);
}
    else; {
        item = this.findNearestItem();
        if (item) {
            itemPos = item.pos;
            itemX = itemPos.x;
            itemY = itemPos.y;
            this.moveXY(itemX, itemY);
}
}
}

This is my code so far, I have tried many things to get passed this level but i just can’t seem to get passed this level
please help


#2

Hello, Kevin. Please read the FAQ prior to your next post, in order to format your code properly. I’ve done it for you this time, but do so yourself in the future.

You have several things wrong with your code. Let’s go over them one by one:

Line 3: if (Flag). Flag shouldn’t be capitalized. You created the variable flag and flag it shall stay.

Line 4: You have no opening curly bracket for your if-statement. This is most irregular, and will break your code.

Line 11: I don’t believe you are supposed to have a semicolon after the else.

Other than that, your code looks fine.


#3

Thanks for the help, I actually didn’t realize I had a semicolon next to my else.