"Python Basics (2015)" was retired on June 22, 2018. You are now viewing the recommended replacement.

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 Arrays Store Multiple Values in an Array Access Array Elements by Index

webdevelopmenthacks
webdevelopmenthacks
6,046 Points

Im trying everything I can to get through this javascript Array Exercise, to no avail!

This is my code, but nothing is working. can someone help?

script.js
const players = ['Toni', 'Anwar', 'Mali', 'Carlos', 'Cormac', 'Sariah'];

players[0];
players[1];
players[2];
players[3];
players[4];
players[5];

console.log( players[0] ); // "Toni"
console.log( players[1] ); // "Anwar" 
console.log( players[2] ); // "Mali" 
console.log( players[3] ); // "Carlos"
console.log( players[4] ); // "Cormac"
console.log( players[5] ); // "Sariah"

1 Answer

Steven Parker
Steven Parker
243,306 Points

First, these lines don't actually do anything and can be omitted:

players[0];
players[1];
players[2];
players[3];
players[4];
players[5];

For task 1, the instructions say "Start by logging the first name inside the array using the console.log() method." Note that it is asking for only the first name, not all of them.

For task 2, it says "On the next line, use console.log() to log the last element inside the players array." So you'll add one more line to also output just the last name.