I am using list.js for pagination and I am trying to count items in list by category. Here i have a list 7 people, of which : 1 is born in 1970, 2 are born in 1983, and 4 are born 1993. So i am trying to count only people born in 1993 and append the result to a span element. I have only managed to count all items/people in the list using:
var initDB = userList.matchingItems.length;
document.getElementById("iDatabase").innerHTML = initDB;
can you please help
You can filter
userList.matchingItemsusing JS'sfilterarray method. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filterOr you can loop over
userList.matchingItemsand count the ones born in 1993.