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 JavaScript and the DOM (Retiring) Traversing the DOM Using parentNode to Traverse Up the DOM

Code will not work

I keep getting this error message for my last line of code: Uncaught SyntaxError: Unexpected end of input

addItemButton.addEventListener('click', () => { let ul = document.getElementsByTagName('ul')[0];
let li = document.createElement('li'); li.textContent = addItemInput.value; ul.appendChild('li'); addItemInput.value = ' '; });

1 Answer

Steven Parker
Steven Parker
231,008 Points

This snippet doesn't explain that particular error, there's likely a problem elsewhere in the code (it's always a good idea to share all the code, preferably as a link to a snapshot of your workspace).

But one issue that stands out is that variable names should never be enclosed in quotes:

   ul.appendChild(li);   // not 'li'

Okay, thanks! I went back through and re-watched a video and fixed everything.

Steven Parker
Steven Parker
231,008 Points

Kelsey George — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!