如何找到当前成员的数量总计 json文件"成员"使用javascript(或jquery),给出" cccrEXP"俱乐部会员有效期是?请注意,有效的成员总数会忽略成员资格已过期的成员。
var members =
[
{ "Name": "Ahmed, Jamshed", "cccrEXP": "2018.10.10" },
{ "Name": "Attaya, James J", "cccrEXP": "2019.1.12" },
]
答案 0 :(得分:1)
按cccrEXP
过滤它们并获取返回数组的length属性
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)