Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
How can I get the number of items in a filtered array in JavaScript

I was trying to divide the number of items in a filtered array but it kept showing me undefined, NAN, or the number of letters in that particular filter when I send it to the console. But what I want to get is the number of items in the filter.

Here is the code I wrote: for (let i = 0; i < categories.length; i++) {

categories[i].addEventListener('click', (e) => {

    const filterF = e.target.dataset.category;

    dogProducts.forEach((product) => {
        if (product.classList.contains(filterF)) {
            product.style.display = 'block';
            ulTag.style.display = 'none';

            console.log(products);

        } else {
            product.style.display = 'none';
            ulTag.style.display = 'none';
        }

    })
})

}

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!