如果"cccrEXP“是俱乐部会员的到期日期,我如何使用javascript (或jquery)找到 json文件" members”的当前会员总数?请注意,有效的成员总数将忽略那些成员资格已过期的成员。
JSON
var members =
[
{ "Name": "Ahmed, Jamshed", "cccrEXP": "2018.10.10" },
{ "Name": "Attaya, James J", "cccrEXP": "2019.1.12" },
]
发布于 2018-06-12 04:47:15
根据cccrEXP
对它们进行过滤,并获取返回数组的长度属性
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)
https://stackoverflow.com/questions/50805689
复制相似问题