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

Phuc Le
Phuc Le
5,182 Points

It looks like Task 1 is no longer passing.

I don't know what this error means?

The task just asked print to console the last item of array.

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>

1 Answer

andren
andren
28,558 Points

It means exactly what it says, this challenge is divided into two tasks, the first asks you to print out the first item of the array and the second asks you to print out the last. When doing challenges you need to keep the code of all the tasks around, you are usually not meant to remove or change code from the previous task.

Since you no longer have the code to print the first item of the array your code no longer passes task 1. If you add that code back like this:

var players = ['Jim', 'Shawna', 'Andrew', 'Lora', 'Aimee', 'Nick'];

console.log(players[0]);
console.log(players[5]);

Then you will be able to pass the challenge.

Phuc Le
Phuc Le
5,182 Points

It worked :D. Thank you.