How is "list" in the for loop connecting to the length of the array playList?

In the for loop, the loop is running as long as i < list.length, but I don't understand how the list is connecting to the amount of items in the playList array. How did this function determine that there were 6 items in the array?

4 Answers

Thanks Chris! I was confused on how "list" was connected to the amount of items in the array "playList". But now i understand. "list" only receives a value once the function is called. At the very end the program the function is called like this:


Since the array "playList" was passed in the function, the function runs and .length will count the amount of items in playList.

Pro Student 43,382 Points

For this video?

There the condition for the loop is i < songs.length where songs is passed in as a parameter.

If not could you provide a link?

Hi Kris,

Thanks for the response, its actually for this video:

chris robinson
chris robinson
2,648 Points

It determines that there were six items in the array by the length property, length will return all values so when the code is ran the program will see and identify all that are in the collection