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 trialArne Ellenberg
2,353 PointsChallenge 3/3 should be solved this way but just isn't...
I tried different ways:
sports [3]
sports [sports.length - 1]
I just don't get it. Please help!
thx
String bestSport = "";
String[] sports = {bestSport, "Basketball", "Baseball", "Tennis" };
int numberOfSports = sports.length;
String lastSport = sports[numberOfSports - 1];
Arne Ellenberg
2,353 PointsThx Arne! ;-)
Arne Ellenberg
2,353 PointsOh, you're so welcome!
Arne Ellenberg
2,353 PointsArne Ellenberg
2,353 PointsTake the variable bestSport out of the array!!!
Then you initialize it with:
lastSport = sports[sports.length - 1];
bestSport should be:
bestSport = sports[0];