<div>
<div class=category> Special Occasions </div>
<div class=category> Holidays </div>
<div class=category> Graduations </div>
<div class=category> Retirements </div>
</div>
<ul>
<li class="product-filter-items">Special Occasions</li>
<li class="product-filter-items">Retirements</li>
<li class="product-filter-items">Graduations</li>
<li class="product-filter-items">Holidays</li>
</ul>
<script>
let proCatList = document.querySelectorAll(".category")
let proFilterItems = document.querySelectorAll(".product-filter-items")
for(let i = 0; i < proFilterItems.length; i++){
proFilterItems[i].addEventListener("click", function(){
if (proCatList[i].textContent.toUpperCase().replace(/[\n\r]+|[\s]{2,}/g, ' ').trim() == proFilterItems[i].textContent.toUpperCase().replace(/[\n\r]+|[\s]{2,}/g, ' ').trim()){
proFilterItems[i].classList.add("active-filter")
console.log("Class Added")
}
})
}
</script>
I am attempting to apply a class when clicked. My goal is to add the class "active-filter" if the category name matches the product filter item clicked. Can anyone assist in identifying why the textContent of proCatList is not being recognized in this statement?