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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Ryan Schmelter](https://secure.gravatar.com/avatar/dcd4885c8036248b5fb3d2155e28d3ec?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ryan Schmelter
9,710 PointsIn this video, does playList take the place of list when the function is called?
I'm confused about why he put -- list -- as the parameter of the printList function. Am I correct to say that in the code -- printList(playList); -- (playList) takes the place of (list) to run the array through the code. If so, why not simply use (playList) as the parameter instead of making a new one?
2 Answers
![Annalyn Sarmiento](https://secure.gravatar.com/avatar/20b143f853fcec22e2da38a477bd3e99?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Annalyn Sarmiento
10,026 Pointsvar playList = [
'I Did It My Way',
'Respect',
'Imagine',
'Born to Run',
'Louie Louie',
'Maybellene'
];
function print(message) {
document.write(message);
}
function printList ( list ) {
var listHTML = '<ol>';
for (var i = 0; i < list.length; i += 1) {
listHTML += '<li>' + list[i] + '</li>';
}
listHTML += '</ol>';
print(listHTML);
}
printList(playList);
In this code, you're correct that list is the parameter of the printList function. When we call the function we pass the array stored in the variable playList into the function.
You could use playList as the parameter in the printList function, but using an arbitrary parameter, like list, allows the function to be reused for other arrays that may be created.
For example, say you create a new array called newList. You would simply have to call the function again, this time passing in the array newList :)
var playList = [
'I Did It My Way',
'Respect',
'Imagine',
'Born to Run',
'Louie Louie',
'Maybellene'
];
var newList = [
'one',
'two',
'three',
'four',
'five',
'six'
];
function print(message) {
document.write(message);
}
function printList ( list ) {
var listHTML = '<ol>';
for (var i = 0; i < list.length; i += 1) {
listHTML += '<li>' + list[i] + '</li>';
}
listHTML += '</ol>';
print(listHTML);
}
printList(playList);
printList(newList);
![edinjusupovic](https://uploads.teamtreehouse.com/production/profile-photos/7286162/micro_furum.jpg)
edinjusupovic
5,664 PointsCould you post the code please.
Alexander Sakaev
Courses Plus Student 1,757 PointsAlexander Sakaev
Courses Plus Student 1,757 PointsIt is basically can be any name in the parentheses.
function printList ( xxx ) { .....}
Clay Bowser
6,619 PointsClay Bowser
6,619 PointsWow that's so cool, thanks for the explanation!