// 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