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 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
229,744 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
229,744 Points

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