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 Multidimensional Arrays Create a Multidimensional Array

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

https://w.trhou.se/t981rdlgj9

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
11,820 Points

Hi jasonj7,

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

createListItems(playlist)

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.

David Lima
David Lima
4,131 Points

This helped a lot. Thank you very much.

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.