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 One Solution

Raul Cisneros
Raul Cisneros
7,319 Points

Hmm..the video does not match the 8 questions I have. Oh well, it was still fun, and great practice.

// 4: Set the class of the <ul> to 'list'
let ulElement;
let challenge4 = () => {
    ulElement = document.querySelector('ul');
    ulElement.className = 'list';
}
challenge4();
// 5: Create a new list item and add it to the <ul>
let challenge5 = () => {
    let listItem = document.createElement('li');
    let inputElement = document.createElement('input');
    ulElement.appendChild(listItem); // ulElement created in question 4.
    listItem.appendChild(inputElement);
}
challenge5();
// 6: Change all <input> elements from text fields to checkboxes
let liCount = document.querySelectorAll('ul li'); // Global variable
let challenge6 = () => {
    for(let i = 0; i < liCount.length; i++) {
        let inputSelect = document.querySelectorAll('ul li input')[i];
        inputSelect.setAttribute('type', 'checkbox');
    }    
}
challenge6();

On question 5 I was having an issue with the check box and the text. I ended up omitting the text since it wasn't called for in the question. The issue I was having was that the checkbox always appeared after the text instead of before. What I wanted was...

<ul>
  <li input type='checkbox'>
  'new text'
  </li>
</ul>

but instead I would get...

<ul>
  'new text'
  <li input type='checkbox'>
  </li>
</ul>

I tried rearranging some of the lines, but it would only break the code. This is not a big deal since this is only practice, but if anyone can understand what ive typed and have any tips ill take them. Thanks!