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 trialLucas Santos
19,315 PointsThis task is not passing me, I have the correct answer.
Now, use console.log() to log out the last item in the array.
var players = ['Jim', 'Shawna', 'Andrew', 'Lora', 'Aimee', 'Nick'];
console.log(players[5]);
Not letting me pass and I have no idea why.. I even tried players.length
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
3 Answers
Jonathan Grieve
Treehouse Moderator 91,253 PointsYea this one has the potential to catch one or 2 out.
You need to make sure you keep the answer to the first task in the code. So answer the second part like this.
var players = ['Jim', 'Shawna', 'Andrew', 'Lora', 'Aimee', 'Nick'];
console.log(players[0]);
console.log(players[5]);
ajloveskats
6,421 PointsJust had the same problem. This can be easily fixed with clearer instructions.
Walt Ribeiro
4,496 PointsWhen this challenge loads, the original code is no present. So there's no way of knowing why there's an error. This challenge should be updated to reflect a correct answer when the original code is not present.
Lucas Santos
19,315 PointsLucas Santos
19,315 PointsThey should really change that to let you pass if it has that extra line or not.
Jonathan Grieve
Treehouse Moderator 91,253 PointsJonathan Grieve
Treehouse Moderator 91,253 PointsPossibly. But there is the notice in each challenge that the code from the last challenge should be added to. That said the doubt is definitely there whether to add a second log or just change the array idnex. Thankfully I got it right on my first go.
Maybe send some feedback to Dave on the Stage feedback button. :-)
Anusha Lee
Courses Plus Student 14,787 PointsAnusha Lee
Courses Plus Student 14,787 PointsThank you, Jonathan. I got this problem, too. Now I finally pass.