Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript DOM Scripting By Example Adding and Removing Names Removing Names

Aakash Srivastav
seal-mask
.a{fill-rule:evenodd;}techdegree
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,625 Points

Removing Names

When we can access , the value of "input" variable inside the function like li.textContent = input.value , is it necessary to increase the complexity by giving parameter to the function ?

1 Answer

Hello Aakash, What you wrote will limit the reusability of the function. Functions in general are created to be used more than once, so for example our function in that example called createLI(text) and by removing its parameter and alter this line of code li.textContent = text; inside it to be li.textContent =input.value; then you can't use this function in other places to create an li element in general as its name implies, it will be just dedicated to create li element that its value comes from the input.