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

Errors on this Javascript Workspace (by default)

Hi,

I'm not sure whether its a error in my code or not, but in the last few workspaces in the Javascript / DOM Manipulation videos, we get null errors on the button clicks:

Here is the javascript:

const toggleList = document.getElementById('toggleList');
const listDiv = document.querySelector('.list');


const descriptioninput = document.querySelector('input.description');

const descriptionp = document.querySelector('p.description');

const descriptionbutton = document.querySelector('button.description');

const addItemInput = document.querySelector('input.addItemInput');
const addItemButton = document.querySelector('input.addItemButton');




toggleList.addEventListener('click', () => {
 if (listDiv.style.display == 'none') {
  toggleList.textContent = 'Hide list';
  listDiv.style.display = 'block';
} else {
  toggleList.textContent = 'Show list';
  listDiv.style.display = 'none';    
}

  });



descriptionbutton.addEventListener('click', () => {
       descriptionp.innerHTML = descriptioninput.value + ':';                 

 });



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

 li.textContent = addItemInput.value;
 ul.appendChild(li);


 });

Here is the error message in browser when loading the JS / clicking the buttons. https://ibb.co/e2qe6S

I've tried loading a video I've not yet watched and launched the Workspace. And the errors exist in there too.

Any ideas?

Thanks