Blind Distance Java Script


#1

does any body know how to pass blind distance on javascript it annoys me. this is what i type in .

// Tell the wizard the distance to the coming ogres.

// This function finds the nearest enemy and returns the distance to it.
function nearestEnemyDistance() {
    var enemy = hero.findNearestEnemy();
    // If there is no enemy, the function returns 0.
    var result = 0;
    if (enemy) {
        result = hero.distanceTo(enemy);
    }
    return result;
}

while (true) {
    var enemyDistance = nearestEnemyDistance();
    if (distance > 0)
        hero.say(distance);
}

#2

my problem is I cant understand the distance thing on line 19
and I can’t get line 21 please help me anybody


#3

You save the result of nearestEnemyDistance to enemyDistance not to distance.

distance is not a “magic” word. It’s just a variable name and you haven’t defined it.


#4

thank you sir for helping me.


#5

Sir what do i do on line 22


#6

// Tell the wizard the distance to the coming ogres.

// This function finds the nearest enemy and returns the distance to it.
function nearestEnemyDistance() {
var enemy = hero.findNearestEnemy();
// If there is no enemy, the function returns 0.
var result = 0;
if (enemy) {
result = hero.distanceTo(enemy);
}
return result;
}

while (true) {
// Call nearestEnemyDistance() and
// save the result in the variable enemyDistance.
var enemyDistance = nearestEnemyDistance();
// If the enemyDistance is greater than 0:
var enemyDistance = nearestEnemyDistance();
if (hero.distanceTo > 0)
// Say the value of enemyDistance variable.
hero.say(distance);
}


#7

Is this code that i wrote right sir


#8

My friend is doing python and he looks up the anwsers and cheats and passes me. I try to do it the right way.


#9

if (enemyDistance > 0) {


#10
// This function finds the nearest enemy and returns the distance to it.
function nearestEnemyDistance() {
    var enemy = hero.findNearestEnemy();
    // If there is no enemy, the function returns 0.
    var result = 0;
    if (enemy) {
        result = hero.distanceTo(enemy);
    }
    return result;
}

while (true) 
    // Call nearestEnemyDistance() and
    // save the result in the variable enemyDistance.
    var enemyDistance = nearestEnemyDistance();
    // If the enemyDistance is greater than 0: 
    if (enemyDistance > 0) {
        // Say the value of enemyDistance variable.
        hero.say(distance);
}

#11

is this correct Mr. Bryukh


#12

if it works then it’s correct. Please don’t post solutions here.


#13

sir, what do i do on line 21


#14

are you ignoring me mr. bryukh


#15

Is it a question? Try to run and you’ll see.

Is it a question? I don’t know what do you do on line 21 because the code has 20 lines.

No. Do you think I watch the forum all time and all post? If you want to ask me something, it’s better to use mentions and I’ll get a notification.


#16

I am sorry Mr.Bruyukh :cry:


#17

I asked that because you usually replied the day I asked you something.But last time you didn’t text me for 2 days.


#18

No problem. I didn’t get those phrases are questions. Could you explain your currnet problem?


#19

Sir i meant line 21 with the extra comments that pop up when you reload it


#20
hero.say(distance);

You don’t have distance variable in your code so it’s undefined. Think where you store the result of the function and use it.