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 trialKelsey George
7,504 PointsCode 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
231,268 PointsThis 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'
Kelsey George
7,504 PointsKelsey George
7,504 PointsOkay, thanks! I went back through and re-watched a video and fixed everything.
Steven Parker
231,268 PointsSteven Parker
231,268 PointsKelsey George — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!