[SOLVED] Help - The Hunt Begins

``````// Senick is trying to find the elusive Burleous Majoris!
// "But he doesn't know how big a Burleous Majoris would be..."
// Find the average size of this burl population to use as a baseline!

// This function returns average size of all the burls in an array.
function averageSize(burls) {
var sum = sumSize(burls);
// Remember the average is the sum of the parts divided by the amount!
return sum / burls.length;
}

// This function should return the sum of all the burls sizes.
function sumSize(burls) {
// Implement the sum function using the burls 'size':
var cumulator = 0;
for (var i = 0; i < burls.length; i++) {
var burl = burls[i];
if (burl) {
var burlHealth = burl.health;
cumulator = cumulator + burlHealth;
}
}
return cumulator;
}

while(true) {
// Find the average size of the burls by calling the 'averageSize' function.
var animals = hero.findByType("burl");
var average = averageSize(animals);
// Say the average size of the seen burls!
hero.say(averageSize(animals));
}

``````

Instead of this, put the variabile average.

put this

``````burl.size
``````

And in rest it looks fine to me.

Thanks i’ll try it now

Tell me if it works now, please.

Thank you so much I’ve been struggling with this for a while. It worked.

Then, select the solution and write [SOLVED] in the title before the word Help.

Okay. I’ve done that.

Now, select the message that helped the most and click on the Solution for that message. And after that you’re done with this topic.

Okay. I’ve done that as well.

Congratulations! This is how you let everyone know that you do not have any more problems and congratations for completing the level!

1 Like