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
Why function createLI(text)
Why function has to have parameter TEXT ??
and what `
return li; on the end on function actually does ??
Melvin RayCourses Plus Student 6,312 Points
Within the function that calls createLI(text), there is a const that we can use to inspect or change the list item (li) that createLI(text) creates. The parameter, text, that is passed to createLI(text) is the part of the list item that is visible on the browser. It's the "banana", say, in the following unordered list(ul). <ul> <li>apple</li> <li>banana</li> <li>orange</li> </ul>
What you see on the page is:
text is the value of the input field, this is the parameter. The argument will be each individual input received, it is also the name given to a list item (li) via textContent property. The function we created is to create a list item, the parameter is text, the input value that is used to name the 'li' item.
functions always return a value, a function that lacks an explicit return statement will return undefined