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

Libor Gess
Libor Gess
6,880 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,880 Points

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