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

Oops! It looks like Task 1 is no longer passing.

I keep getting: "Oops! It looks like Task 1 is no longer passing." but my code seems correct

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>

What's the task's question?

The script.js file contains an array of string values -- the names of players in a game. Let's practice using array indices to access individual names in the array. Log the first name of the array using the console.log() method.

3 Answers

Josh Salyer
Josh Salyer
7,265 Points

With most of these challenges with multiple steps, they want you to ADD code to what you already have (most of the time). So in your case, simply log the last element in the array to the console on a new line after logging the first element:

var players = ['Jim', 'Shawna', 'Andrew', 'Lora', 'Aimee', 'Nick'];
console.log(players[0]);
console.log(players[5]);

Hi, your not logging the first player. I only looked at the first question. If the second question asks for something else you usually need to leave the first answer there

This is what it needs to look like to pass

var players = ['Jim', 'Shawna', 'Andrew', 'Lora', 'Aimee', 'Nick'];
console.log(players[0])
console.log(players[5])

Ah apologies, makes sense :) i updated 0 to 5 instead of adding another console.log like you have shown thank you!