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.

Seth M
Web Development Techdegree Student 12,271 PointsIs there any issue with using for of loops instead of the basic for loop?
I solved the filter checkbox problem like this:
filterCheckBox.addEventListener('change', (e) => {
const isChecked = e.target.checked;
const lis = ul.children;
if (isChecked) {
for (each of lis)
if (each.className === 'responded') {
each.style.display = '';
} else {
each.style.display = 'none';
}
} else {
for (each of lis) {
each.style.display = '';
}
}
});
I felt that for of loops were neater and quicker to write. Is there any problems with this approach?
Thanks!
1 Answer

Steven Parker
216,033 PointsAs you discovered, it's an effective and concise approach, so you're likely just getting ahead of things. Unless for ... of
was introduced earlier in this same course, it was probably not used to avoid any confusion.
Seth M
Web Development Techdegree Student 12,271 PointsSeth M
Web Development Techdegree Student 12,271 PointsThanks Steven! Insightful response as always!