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 Multiple Items with Arrays Two-Dimensional Arrays

Shouldn’t line 1’s var playlist be var songs?

…so that the songs.length make sense?

1 Answer

Steven Parker
Steven Parker
218,815 Points

The parameter is given the name "songs" in the function declaration, so that name is used throughout the function. But a parameter is only a placeholder for the actual argument that is passed when the function is called.

The actual variable name passed in doesn't need to be the same as the parameter name, and in fact it's usually considered good practice to not use exactly the same name to avoid possible confusion when reading the program. But it is also good practice to have the names somewhat descriptive of what they contain, and both "songs" and "playlist" meet this criteria.

aah...I'm still mixing up parameters and arguments. So much information in one day my brain is hurting.... Thank you so much, Steven, for clearing that up for me (and so fast too!). 😭😭

Steven Parker
Steven Parker
218,815 Points

The speed was simply coincidence, but I'm glad I could help. Happy coding!