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

michael edmondson
michael edmondson
4,510 Points

how is 'songs' parameter in the function linked to the the playlist array im lost on that

var playList = [ ['I did it my way', 'Frank Sinatra'], [ 'Throwaway', 'Aretha Franklin'], [ 'Money power respect','Jay z'] ];

function print(message) { document.write(message); }

function printSongs( songs ) { var listHTML = '<ol>'; for ( var i = 0; i < songs.length; i += 1) { listHTML += '<li>' + songs[i][0] + ' by ' + songs[i][0] + '</li>'; } listHTML += '</ol>'; print(listHTML); }

printSongs(playList)

1 Answer

Steven Parker
Steven Parker
229,968 Points

Parameters are only placeholders for the actual values that will be passed in later. Look at the code where the function is called:

printSongs(playList)

The "playList" is passed in as the function argument. The parameter "songs" then takes on the value of "playList" while the function runs.

michael edmondson
michael edmondson
4,510 Points

ooooohhhh ok thanks i didnt catch that at the bottom