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.


Jorge Marlon Allen Soler
Jorge Marlon Allen Soler
435 Points

difference btw creating node with Appendchild vs brute text ex : '<li></li>'

So the teacher solution create all the li with back quotes but I appendchild and create element. here is my code : function builder (data) { const div = document.getElementById("employeeList"); const ul = document.createElement("UL");

for (let i = 0; i < data.length; i++)
    let li = document.createElement("LI");

    if (data[i].inoffice == true)
    li.textContent = data[i].name;

}; Which method is better and why? Thanks in advance

1 Answer

Steven Parker
Steven Parker
210,812 Points

You forgot to provide a reference to the course example, but just in general there are often multiple ways to accomplish a specific thing.

In more complex code you may find that one method might save some steps or otherwise make the code more efficient compared to the alternatives. But in simple cases, such as many of the course examples, it may not really make a difference which method you use.