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

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.

console.log(Jim[0]); my code keeps on saying bummer

Rebecca Ung
Rebecca Ung
5,031 Points

it goes like this

console.log(players[0]);

because you are supposed to put the variable in t

6 Answers

Almost had it, you need to replace "Jim" with "players."

console.log (players[0]);

The 0 is what is calling the first name of the array (Jim)

Jim is not a list. Players are Array.

console.log(players[0]);
A Laypanov
A Laypanov
27,579 Points

I don't see your code, but I think "Jim" is the first string in the array "names". So to access it you should place index of the string after name of the array: names[0]

i've typed this but still giving me this massage "Bummer! Remember arrays are 'zero-indexed' meaning the first item in the array is at position 0." where am i going wrong var players = ['Jim', 'Shawna', 'Andrew', 'Lora', 'Aimee', 'Nick']; console.log (players[0]); console.log (players[1]); console.log (players[2]); console.log (players[3]); console.log (players[4]); console.log (players[5]);

i've typed this but still giving me this massage "Bummer! Remember arrays are 'zero-indexed' meaning the first item in the array is at position 0." where am i going wrong var players = ['Jim', 'Shawna', 'Andrew', 'Lora', 'Aimee', 'Nick']; console.log (players[0]); console.log (players[1]); console.log (players[2]); console.log (players[3]); console.log (players[4]); console.log (players[5]);

the correct answer is:-

console.log(players[0]);