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.
The question reads as follows: Use console.log() to log out the last item in the array. var players = ['Jim', 'Shawna', 'Andrew', 'Lora', 'Aimee', 'Nick'];
Here's my answer: console.log(players);
I've tried all numbers from one through six and nothing works.
var players = ['Jim', 'Shawna', 'Andrew', 'Lora', 'Aimee', 'Nick']; console.log (players);
The first index you tried (5) is indeed the correct one. The issue is that you have removed / changed the code you wrote in task 1. Below the challenge description of every task the following text is written:
Important: In each task of this code challenge, the code you write should be added to the code from the previous task.
What that is trying to tell you is that for multi-part challenges you should not remove previous parts, but add to them. When you try to check your code the challenge checker will run all of the tests from all of the tasks it has given you so far, and if your code does not pass all of them (not just the test for the current task) then it will be marked invalid.
So if you add the code for task 1 back like this:
var players = ['Jim', 'Shawna', 'Andrew', 'Lora', 'Aimee', 'Nick']; console.log(players); console.log(players);
Then your code will pass.