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 Tracking Data Using Objects The Build an Object Challenge, Part 2

Vic Mercier
Vic Mercier
3,276 Points

student = students[i];

If I understand well that means the student variable can change?

2 Answers

Stuart Wright
Stuart Wright
41,102 Points

That line of code would appear inside your for loop, where i is greater than or equal to 0, and less than the length of your array.

student = students[i] will then result in the item at index i in the array being assigned to variable student.

Gustavo Winter
PLUS
Gustavo Winter
Courses Plus Student 27,382 Points

Every time the looping run the variable "i" will get one valor. Each valor represent a objects inside your array, Ex: [0, 1, 2, 3, 4]

In each loop the variable "student" asborve the array content. Obs: every looping the variable "i" will added by 1. At the end of every loop the result of "student" appears at the screen.

student= students[i];