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

Lewis Morgans
Lewis Morgans
3,167 Points

console.log(players[5]); is actually correct? but says it's not...

Says to console log the last item in the array, which is at position 5.

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>

3 Answers

Steven Parker
Steven Parker
210,423 Points

Perhaps you overlooked the caution displayed by the challenge: "Important: In each task of this code challenge, the code you write should be added to the code from the previous task."

The code shown here is correct for task 2, but the task 1 code seems to be missing.

Tsenko Aleksiev
Tsenko Aleksiev
3,818 Points

You only write 5 instead of 0 to win this challenge, but you have to have both of them ( one per line ) otherwise, yes console.log(players[5]); is true :)

John Lott
John Lott
5,459 Points

I'm having the same issue.

var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];

months.join(', ');

console.log(months[11]);

Steven Parker
Steven Parker
210,423 Points

This is clearly from a different challenge. Try starting a new question and be sure to show your code and provide a link to the course page.

In the meantime, one hint: the string for "join" should go on the left, and the list should be the argument.

John Lott
John Lott
5,459 Points

Hi Steven. I apologize as I am a little new to how this message board works. Thanks for advice. I will submit a new question.