I don't know why my hero keeps dying on Zig Zag And Zoom


#1
// Escape from Death Valley!
// The archers firing at you are not your allies! Dodge the arrows!
// Move by with a zigzag pattern using real modulo functions.

// This function returns a value from 0 to 15:
function mod15(n) {
    while (n >= 15) {
        n -= 15;
    }
    return n;
}

// This function should return a value from 0 to 9:
function mod9(n) {
    while (n >= 9) {
     n -= 9;   
    }    
    return n;
}

// Don't change the following code:
while (true) {
    var time = hero.now();
    var x, y;
    if (time < 30) {
        y = 10 + 3 * mod15(time);
    } else {
        y = 20 + 3 * mod9(time);
    }
    x = 10 + time;
    hero.moveXY(x, y);
}

That’s my code. It should work but I don’t know why it won’t; it just kills the hero every single time. I even checked for the solution on Github.


#2

Could you send me (here or with a direct message) your CodeCombat username? I’ll check the problem.


#3

LittleWhole is my CodeCombat username.


#4

I checked this level with your account and it works fine. Also, it looks like it completed already.


#5

Yeah, it somehow worked after…