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

Libor Gess
Libor Gess
6,563 Points

Code challenge of arrays

I am doing practice of arras and I am getting an error of question: Now, use console.log() to log out the last item in the array.

So I did fallowing:

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

But I got this error: Bummer: Use [ ] and a number to access an item in an array: players[0]

Please could someone explain why I am getting this error? Thank you?

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

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Libor Gess! You're doing really well, but these challenges are cumulative. This means that the original console.log() from task 1 should still be there. You should have one console.log() that logs out the first player, then in step 2, you add a new console.log() that logs out the last player. Take a look at this informational note in the challenge where the "Bummer!" message would be before you hit "Check work".

Important: In each task of this code challenge, the code you write should be added to the code from the previous task.

Hope this helps! :sparkles:

Libor Gess
Libor Gess
6,563 Points

Ohh yes thank you now the error make seance . Thank you.