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

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)

ellie adam
ellie adam
26,376 Points

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]);