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

what is [i] mean for ?

got some question,

so my code like this:

var students = [ { name: 'AAA', track: 'IOS', achievements: 001, points: 111 } ];

for (var i = 0; i < students.length; i++) { console.log('name:' + students[i].name); }

and my question is what is > student[i].name < i meaning for ? i have no idea what is that

2 Answers

Steven Parker
Steven Parker
243,318 Points

This code is in a loop where "i" is the index number of a student record, so "students[i]" is the record of a particular student, and "students[i].name" is the name of that student stored in the record.

Thank you !

when you run a for loop, i represents the value that you are on in your students array