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 Encapsulation and Arrays Arrays

Nick Torchio
Nick Torchio
912 Points

Array's

My prompt is to set the third value in the array to lap3. Whenever I check this all it asks is "Did you index into the third value". I want to say yes?

I'm mostly lost because all of the errors that I receive are yes or no questions that I can answer yes to. Because of this I really don't know where to find the problem. A prior error was that I hadn't set lap3 to a double, so I added a line in there for that. I've been playing around with the lines for a few minutes now and I always get the same errors that don't give me any indicators as to where the real issue is occurring.

CodeChallenge.cs
double[] lapTimes = new double[4];
lapTimes[0] = 2.2;

double[] finalLapTimes = new double []{2.2, 2.3, 2.5, 2.8};
double lap3 = lap3;
finalLapTimes[2] = lap3;

1 Answer

Steven Parker
Steven Parker
231,198 Points

It looks like you performed the instruction backwards.

You "set the third value in the array to lap3.", but the actual task 4 challenge instruction says "Set lap3 to the value in the third item of the finalLapTimes array."

So if you reverse the assignment operands you should pass.

Also, I don't think it's legal to declare a variable and assign it to itself in the same statement. But you can declare and assign it with something else, that's a standard initialization.

Nick Torchio
Nick Torchio
912 Points

I can't believe I misread that over and over for a thousand times and still never put that together. Thanks you Steven.