JavaScript JavaScript Arrays Multidimensional Arrays Create a Multidimensional Array

On Create a Multidimensional Array video I can't see the link between playlist and function createListItems

I have done research (with help from Jennifer Nordell) to better understand arguments and parameters, however with the above program I am struggling.

I get that arr is a parameter and placeholder, but what are the arguments that are imported to the function? I cannot see a visual link from the function into the playList.

Does arr stand for array? but the array is called playList? If arr is a parameter is arr.length an argument? as well as ${ arr[i][0] }? Maybe I'm being a bit slow here however this program has me scratching my head...

Thanks for any help.

2 Answers

Cameron Childres
Cameron Childres
Treehouse Moderator 11,695 Points

Hi jasonj7,

On line 25 the createListItems() function is called like this:


This is where "playlist" is given as an argument to the function. An argument is the data that we're passing to the function that takes place of the parameter when it runs. In this case "playlist" represents an array, as defined on line 1.

The function used "arr" as a parameter when it was defined. When we call it with "playlist" the function runs with "playlist" replacing every instance of "arr" in the function definition -- such as arr.length becoming playlist.length and returning the length of the "playlist" array.

Hopefully this helps clear some things up! Don't hesitate to ask if you have any questions.

hmmm starting to make me think, I need to keep doing this, you know when somethings hard for you and you have to keep on going over and over it before it'll stick... that's me at the minute.

Thanks very much I will read this and do the video associated with your help again tomorrow, feel a bit relieved from your answer. Struggled so much with this issue for a while now.