Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Using Array Indices

juned alam
seal-mask
.a{fill-rule:evenodd;}techdegree
juned alam
Full Stack JavaScript Techdegree Student 4,107 Points

why do i get this wrong?

not sure if it is a bug, because i ran my code on both the console and a online javascript IDE and they both work. it sucks because i cant submit the unit project untill this i pass this challenge.

script.js
var players = ['Jim', 'Shawna', 'Andrew', 'Lora', 'Aimee', 'Nick'];
console.log(players[5]);
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
Shehan Dissanayake
Shehan Dissanayake
19,118 Points

The answer should be console.log(players[0]);

Because it says to log the first player, not the 6 th. if you pass 5 inside [] it logs the 6th player in the array.

index 0 refers to the first values in an array. Thanks

1 Answer

Shehan Dissanayake
Shehan Dissanayake
19,118 Points

The answer should be console.log(players[0]);

Because it says to log the first player, not the 6 th. if you pass 5 inside [] it logs the 6th player in the array.

index 0 refers to the first values in an array. Thanks

juned alam
seal-mask
.a{fill-rule:evenodd;}techdegree
juned alam
Full Stack JavaScript Techdegree Student 4,107 Points

i was specifically referring to the second part of the challenge where it asks to log out the last item, turns out they wanted the solution on a second line, so it should have been: console.log(players[0]) console.log(players[5])

instead of how i just had console.log(players[5])

thanks