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

MAisam Bakhshi
MAisam Bakhshi
7,210 Points

C# array

I didn't get the question. is it asking to create a new variable lap3 and then set the third item in the array to the value of lap3'?

like

double lap3 = 3.0;

finalLapTimes[2] = lap3;

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

lapTimes[0] = 2.2;

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

double lap3 = 3.0;

finalLapTimes[2] = 3.0;

1 Answer

Steven Parker
Steven Parker
229,670 Points

Your setting the wrong value.

For task 4, the challenge says, "Set lap3 to the value in the third item of the finalLapTimes array." But you're setting it to a literal value of 3.0 instead of getting the value from the third item of the array.

And you won't be setting the third item of the array.

It also looks like you altered the task 2 code so it no longer compiles. You'll need to put that back to how it was when you passed task 2.