[SOLVED] JavaScript Won't Work But Python Will - Why?

Hi guys. I have this problem in safe spot and I can’t seem to solve it. I have scoured the forum for other topics but I think that there must be some sort of minor glitch (or major) in it. Help would be appreciated:

// The function checks if numbers are almost equal.
function almostEqual(n1, n2) {
    return Math.abs(n1 - n2) <= 0.5;

// The function checks that all 
// thangs are on the same distance from the hero.
function allSameDistance(thangs) {
    if (thangs.length === 0) {
        return true;
    // We can use any thang as an etalon.
    var etalon = hero.distanceTo(thangs[0]);
    // Iterate all thangs:
    for (var i = 0; i < thangs; ++i) {
        var thang = thang[i];
        // Use almostEqual to compare `etalon` and the distance to `unit`.
        // If they are not equal (almost):
        if (!almostEqual(hero.distanceTo(thang), etalon)) {
            // Return false.
            return false;   
    // All the same. Return  true.
    return true;

var bombs = hero.findEnemies();
for (var x = 36; x <= 44; x++) {
    for (var y = 30; y <= 38; y++) {
        hero.moveXY(x, y);
        if (allSameDistance(bombs)) {
            // It's a safe spot. Rock'n'Roll!
            hero.moveXY(40, 56);

hero.say("Heh. Nothing.");

I have also noticed that some levels don’t work in JavaScript but they work in Python. Why could this be? Thanks for an answer!

Im not exactly sure, but if you just copy and pasted the code and then just wrote it in JavaScript it does not work. I know because I have tried it. that could be why. otherwise I have no clue

Should be i < thangs.length


Ah, silly mistake. Thanks!

1 Like

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