Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Objects Loops and Final Touches For Loops

Not sure why my code isn't compiling - what am I missing on this one?

I'm getting the error below after "Bummer: Your code could not be compiled."

FrogStats.cs(14,8): error CS1525: Unexpected symbol }', expecting;'

I'm not sure what's missing in my code for this challenge problem.

FrogStats.cs
namespace Treehouse.CodeChallenges
{
    class FrogStats
    {
        public static double GetAverageTongueLength(Frog[] frogs)
        {
            double sumTotal = 0;
            for(int i = 0; i < frogs.Length; i++)
            {
                sumTotal = sumTotal + frogs[i];
            }
            var averageTongueLength = sumTotal / frogs.Length;
            return averageTongueLength

        }

    }
}
Frog.cs
namespace Treehouse.CodeChallenges
{
    public class Frog
    {
        public int TongueLength { get; }

        public Frog(int tongueLength)
        {
            TongueLength = tongueLength;
        }
    }
}

1 Answer

Damien Bactawar
Damien Bactawar
8,549 Points

As the complier says you are missing a ";".

return averageTongueLength

When you correct this to "return averageTongueLength;" you get a new error.

I also looked at it and I fixed it but I already answered it for you previously. I advise you to look at how you access an object's attribute.