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 Interactive Web Pages with JavaScript Traversing and Manipulating the DOM with JavaScript Perform: Traversing Elements with children

7,284 Points

In the bindTaskEvents function, are the parameters "taskListItem" and "checkBoxEventHandler" also local variables?

Andrew types "taskListItem" and "checkBoxEventHandler" as the parameters, but the names of these parameters did not exist until written as part of the function. It seems that the function creates the names of the parameters "taskListItem" and "checkBoxEventHandler".

Are these names also considered to be local variables?

I should just go review training on creating functions to get clear on parameters.

1 Answer

Hi Dianna,

If a variable is declared in a function the variable scope is binded to that function only.

If a variable is declared outside a function the variable scope jumps to global -> any function you write, it can see the variable and interact with it: HEADS UP -> be careful with those, if you change the value in a function it value is changed globally.

Hope this shines some light. If not I can send you a flashlight :)