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 trialAakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 PointsRemoving 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
Ahmed Abdellatef
11,095 PointsHello 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.