Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Barry Ort
12,373 PointsWhat is the correct answer?
Everything I try isn't correct.
namespace Treehouse.CodeChallenges
{
class FrogStats
{
public static double GetAverageTongueLength(Frog[] frogs)
{
double sum;
for(int i; i < frogs.length; i++){
double tongue= frogs[i];
sum += tongue;
return tongue / frogs.length;
}
}
}
}
namespace Treehouse.CodeChallenges
{
public class Frog
{
public int TongueLength { get; }
public Frog(int tongueLength)
{
TongueLength = tongueLength;
}
}
}
1 Answer

Chris Adamson
132,142 PointsYou aren't far off, length should be Length, Frog.TongueLength is an Integer, and the temporary tongue double variable isn't needed.
namespace Treehouse.CodeChallenges
{
class FrogStats
{
public static double GetAverageTongueLength(Frog[] frogs)
{
int sum = 0;
for(int i = 0; i < frogs.Length; i++){
sum += frogs[i].TongueLength;
}
return sum / frogs.Length;
}
}
}
Barry Ort
12,373 PointsBarry Ort
12,373 PointsThanks! I didn't know that tongue was an int. in the in the method I saw that it was returning a double so I assumed that the tongue length may be a double.