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 trialSmita Sahoo
864 PointsQues: Set lap3 to the value in the third item of the finalLapTimes array.
I have typed this as my answer: double[] lapTimes = new double[4]; lapTimes[0] = 2.2;
double[] finalLapTimes = new double[4] {2.2, 2.3, 2.5, 2.8}; double lap3 = 2.4; finalLapTimes[2] = lap3;
Not sure what I'm doing wrong. Can someone help please...
double[] lapTimes = new double[4];
lapTimes[0] = 2.2;
double[] finalLapTimes = new double[4] {2.2, 2.3, 2.5, 2.8};
double lap3 = 2.4;
finalLapTimes[2] = lap3;
2 Answers
Jennifer Nordell
Treehouse TeacherThe problem here is that you have the instructions a little backwards. They want the third element assigned to lap3. you've made lap3 and put it in the third element. Take a look:
double lap3 = finalLapTimes[2];
Here we declare a new double (you could also use var
) and put the 3rd element in the new variable. Hope this helps!
Vitaliy Raboshcuk
1,140 Pointsdouble[] lapTimes = new double[4]; lapTimes[0] = 2.2; double [] finalLapTimes = new double {2.2, 2.3, 2.5, 2.8};
var lap3 =null; finalLapTimes[2] = lap3;
Bummer! Did you index into the third item of the 'finalLapTimes' array? what is wrong?
Michael Ford
Courses Plus Student 1,139 PointsYou assigned a null to the variable lap3. You want to assign the value in the third position of the finalLapTimes array.
Answer: var lap3 = finalLapTimes[2];
Goodluck!