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 trial

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
229,644 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,819 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
229,644 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.