Basin Stampede *

I have been working on this level for literally weeks, and nothing has happened.
URL: Https://codecombat.com/play/level/basin-stampede?
I don’t know what’s wrong:

// Keep moving right, but adjust up and down as you go.

while(true) {
    var enemy = hero.findNearestEnemy();
    var xPos = hero.pos.x + 5;
    var yPos = 17;
    //if(enemy) {
        // Adjust y up or down to get away from yaks.
        if(enemy.pos.y > hero.pos.y) {
            // If the Yak is above you, subtract 3 from yPos.
            yPos - 3;
            
        } else if (enemy.pos.y < hero.pos.y) {
            // If the Yak is below you, add 3 to yPos.
            yPos + 3;
            
        }
   // }
    hero.moveXY(xPos, yPos);
}

Hi @Pioneer, welcome to the CodeCombat Discourse.
The problem with your code here is that when you update the yPos variable you’re not using var.
You’ll also need to uncomment the commented out lines (if(enemy) and it’s corresponding closing bracket.)
Finally when you format Javascript could you add “javascript” to the end of the the end of the three backticks. e.g.
```javascript

```
And the comments will turn green.
Thanks
-Danny

yPos - 3; try this instead: yPos -= 3

and try this instead of yPos + 3;(try this: yPos += 3;)

use this instead:

hero.moveXY(xPos + 5, yPos + 3)

# otherwise, use this:
hero.moveXY(xPos + 5, yPos + 3)

did it work Pioneer?

@kayden4444 Pioneer wrote that almost a year ago. He’s got it.

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