-1

How can I find the number of current members total json file "members" using javascript (or jquery), given that "cccrEXP" is the club membership expiration date? Please note that a valid total of members ignores those with memberships that have expired.

JSON

var members = 
[
{ "Name": "Ahmed, Jamshed", "cccrEXP": "2018.10.10" },
{ "Name": "Attaya, James J", "cccrEXP": "2019.1.12" },
]
verlager
  • 794
  • 5
  • 25
  • 43

1 Answers1

1

Filter them by cccrEXP and get length property of the returned array

var members = 
[
{ "Name": "Ahmed, Jamshed", "cccrEXP": "2018.10.10" },
{ "Name": "Attaya, James J", "cccrEXP": "2019.1.12" },
{ "Name": "George, Baily", "cccrEXP": "2018.1.12" },
];

var x = members.filter(o=> new Date(o.cccrEXP) >=new Date()).length;

console.log(x)
Muhammad Usman
  • 10,039
  • 22
  • 39