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.
index.html from the project files, as well as in Workspaces, is missing code
I typically download the project files and use them in a different editor. One of the first things that I do after downloading and importing the files to the editor is open Chrome to do a preview before I do any editing of the HTML, CSS, or JS code. I also immediately open the JS console just to have it open at the start of my editing.
When I did this for this particular video (video 5 files seem to be just fine), there was an immediate error in the console. The error I got is as follows:
"app.js:47 Uncaught TypeError: Cannot read property 'addEventListener' of null at app.js:47"
Inspecting Guil Hernandez 's code in the video, everything was the same as the code that I downloaded. I followed along the video, inputting everything in the lesson in case it was some error that would eventually clear up. The only thing that changed was the line it was referencing where the error occured, and it always stayed within the last event listener.
I also opened up the Workspace for this video, and the app.js file in Workspaces was the exact same as the code for the project files app.js. However, I found that BOTH index.html files did not have the HTML code for the "Remove last item" button (which I had also noticed early on that my browser was not showing the button, even though the browswer in the video was).
I added the HTML code to add the "Remove last item" button into both index.html files, and everything in the browser immediately worked without any errors. It also worked when I added in the code that we edited in this video, so just a heads up to anyone that the button may be missing in their code (and a FYI to the Treehouse folks). I'll copy/paste the original that came in the project files index.html and app.js files below for reference (my apologies for the long post):
Joel KraftTreehouse Guest Teacher
That was indeed a mistake. The
index.html file should have contained the "remove" button, which was producing the error you noticed. I have fixed the issue. Thanks for letting us know about this!