Slumbering Sample javascript

What is wrong? It is always “That is not right”

//var enemies = hero.findEnemies();
var friends = hero.findFriends();
var yetis = hero.findByType(“yeti”, friends);
//hero.say("yeti "+ yetis.length);

function averageSize(yetis) {
var sum = 0;
for (var i = 0; i < yetis.length; i++)
{
var ya = yetis[i];
sum = sum + ya.size;
}
return sum / yetis.length;
}

var a = averageSize(yetis);
hero.say(a);

P.S. Maybe it important, Yeties automaticaly dying at the beginning.

It looks like the problem is in the first four lines.
Try hero.findByType("yeti") instead.
And the yetis are not friends.

Already tried.

var yetis = hero.findByType(“yeti”);
function averageSize(yetis) {
var sum = 0;
// Go through each yak and add its size to the sum.
for (var i = 0; i < yetis.length; i++)
{
var ya = yetis[i];
sum = sum + ya.size;
}
return sum / yetis.length;
}

var a = averageSize(yetis);
hero.say(a);

And var yetis = hero.findByType(“yeti”, hero.findEnemies(); too

If i put hero.say("yeti "+ yetis.length);, it would be “Nan” of yeties.

I don’t know what to do.

Please refresh the page and try again, or improve your glasses. I believe the problem is that you are unable to see the Yetis. I implemented a fix, but fixing your glasses should help, too.

1 Like

Thank you. With new glasses it is ok.