# I NEED HELP PLEASE ! js ( bookkeeper )

i am working on that since 4 h … help me i think its a bug ! if not can u do it for me … i just want to go to the next exercice !!
NAME OF EXERCICE : 24.1-bookkeeper
my code :

``````// Fight enemies for 15 seconds.
// Keep count whenever an enemy is defeated.
var count=0;
while (true) {
enemy=this.findNearest(this.findEnemies());
if (enemy) {this.attack(enemy); count++;}
if(this.now() > 15) break;
}
// Tell Naria how many enemies you defeated.
this.moveXY(58, 33);
this.say(count);
// Collect coins until the clock reaches 30 seconds.
while (true) {
item=this.findNearest(this.findItems());
this.moveXY(item.pos.x, item.pos.y);
if(this.now() > 30) break;
}
// Tell Naria how much gold you collected.
this.moveXY(58, 33);
this.say(this.gold);
// Fight enemies until the clock reaches 45 seconds.
// Remember to reset the count of defeated enemies!
var count1=0;
while (true) {
enemy=this.findNearest(this.findEnemies());
if (enemy) {this.attack(enemy); count1++;}
if(this.now() > 45) break;
}
// Tell Naria how many enemies you defeated.
this.moveXY(58, 33);
this.say(count1);
``````

*** thanks !!!**

Are you counting how many times you attack the enemy or how many times you defeated the enemy?

Which does Naria want?

1 Like

there you have everything , thanks sir

up . please i need help it block me

// Fight enemies for 15 seconds.
// Keep count whenever an enemy is defeated.
var count=0;
while (true) {
var enemy = hero.findNearest(hero.findEnemies());
if (enemy) {hero.attack(enemy); count++;}
if(hero.now() > 15) break;
}
// Tell Naria how many enemies you defeated.
hero.moveXY(58, 33);
hero.say(count);
// Collect coins until the clock reaches 30 seconds.
while (true) {
var item = hero.findNearest(hero.findItems());
hero.moveXY(item.pos.x, item.pos.y);
if(hero.now() > 30) break;
}
// Tell Naria how much gold you collected.
hero.moveXY(58, 33);
hero.say(hero.gold);
// Fight enemies until the clock reaches 45 seconds.
// Remember to reset the count of defeated enemies!
var count1=0;
while (true) {
enemy=hero.findNearest(hero.findEnemies());
if (enemy) {hero.attack(enemy); count1++;}
if(hero.now() > 45) break;
}
// Tell Naria how many enemies you defeated.
hero.moveXY(58, 33);
hero.say(count1);

Hi @Jeremy_Yu and welcome to the forum! Could you format your code property using the button </>?

Hi AnseDra I am sorry I am new to discourse and I don’t know how to format my code property.

What I wrote is my solution to the level.

I told you, use the </> button and put the code between the first three and last three comas

So I passed it I don’t need help just to clarify

Ok. Congratulations!

Oh so do I resendy solution

Do not send the solution.

Oops I meant resend sorry

Wait AnseDra that was my solution in JavaScript and it worked 2 days ago

You should not show the solutions here, on the forum

1 Like

Ok do I delete because u said to not send

I sent because I wanted to help but u said not to send so how do I delete

Ok. Send your code when it doesn’t work.

1 Like