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

Phil J.
PLUS
Phil J.
Courses Plus Student 2,584 Points

Why do JavaScript functions contain a space before and after a parameter?

For example, in this video, (JavaScript Loops, Arrays and Objects: Section 2 Video 15 @6:00) there are spaces surrounding "songs" inside the function printSongs(). I'v been doing it without spaces throughout the whole track.

// How the instructor does it
function printSongs( songs )

vs

function printSongs(songs)

https://teamtreehouse.com/library/twodimensional-arrays

1 Answer

Steven Parker
Steven Parker
231,141 Points

You've been doing it the "best practice" way already. But extra spaces are ignored by the system, and perhaps the instructor was using them just to make the name more readable.

Steven Parker
Steven Parker
231,141 Points

I found what you meant in the video, but I noticed other definitions without spaces (like "print"). At one point in the video that parameter name gets highlighted, perhaps that was done to make it stand out more for that scene.