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 Improving the Application Code Refactor 1: Create List Items

1 Answer

Jason Larson
Jason Larson
7,961 Points

This is not accurate. First, you're not technically removing document. You're replacing the method document.createElement() with a function that you created called createElement(). It might be less confusing if you named the new function something different, like createElemThing() then it will be easier to see that you're not simply removing 'document'. Also, doing this doesn't break anything, as long as the new function is created correctly and you're calling it correctly. In your subject for this, you put Don't remove 'document' from document.createElement(‘span’, ‘textContent’ ‘textEntered’). Note that if this line is in your code, it will indeed cause the button to not work because you are not sending the 3 parameters correctly, as you are missing a comma between 'textContent' and 'TextEntered'. I discovered this myself because mine also broke as you suggested, and then when I was double-checking things, I realized I had a period in one of my calls instead of a comma. Also note that if you inspect your page and look at the console, you should see an error message indicating where the problem is. When I entered my line like you have it, I got the following error in the console:

Uncaught SyntaxError: missing ) after argument list                     app.js:17

The error is not entirely accurate because I'm actually missing the comma after the 2nd argument, but the compiler isn't able to determine that.