##statements ≠ lines
Remove the s from the brackets, because they count as separate statements.
Cheers
##statements ≠ lines
Remove the s from the brackets, because they count as separate statements.
Cheers
Ah I see I didn’t know that was the case. Thank you very much!
your first response worked perfectly. I’m not sure what the significance of this is yet:
while (this.findNearestEnemy() !== null)
this.attack(this.findNearestEnemy());
I guess I’m just too new to the language.
I cannot finish the level. I have done the right code based on all the comments and it doesn’t allow them to go through the door. I am using js.
Am I missing something?
This level is still not working in js. Am I missing something
Please include your code properly formatted inside of three backticks (`) before and after the code.
Forgot to indent.
*This is Python.
It comes up with a problem with the second code but the rest is all good
Please remember to format your code according to the FAQ. As I have explained at various times to other users, it helps us understand the code a little easier. Thanks!
(If you find this helpful, please this post)
Thanks Dude! Helped me so much!!!
Here’s my code
while True:
hero.moveRight()
hero.moveUp()
hero.moveRight()
enemy = hero.findNearestEnemy()
hero.attack(enemy)
hero.attack(enemy)
hero.moveDown(2)
hero.moveUp(1)
Please format your code according to the FAQ. It helps understand your code better. It basically helps us help you!
Also, could you give some information on what is going wrong, what the game is saying etc.
Cheers!
(Please this post if it helps!)
sorry I replied so late guys
[redacted, please don’t post solutions]
I used this and it worked
won’t work… I have to use hero.move instead of self.move
You are the best thanks for the help
It worked thanks!!!
Hey. I am doing LUA and I can’t get pass this level.
I’ve been trying to figure out how to do this for like 10 minutes, and I can’t seem to figure out how. I’m using Javascript. Here’s my code:
var enemy = hero.findNearestEnemy();
while (true) {
hero.moveRight();
hero.moveUp();
hero.moveRight();
hero.moveDown(2);
hero.moveUp();
hero.enemy;
hero.attack(enemy);
hero.attack(enemy);
}
I’ve tried sticking this part in all the different spots I can think of, but it always runs the code early, and it says that there isn’t an enemy in my line of sight.
hero.enemy;
hero.attack(enemy);
hero.attack(enemy);
Am I doing something wrong, or is the game bugging out?
Please format your code according to the FAQ. It makes it easier to understand your code.
your are missing I think if enemy
in that.
https://discourse.codecombat.com/faq