我想过滤以下两个数组并获取"isimplemented: 'Yes'"
元素的数量:
const arr1 = [{ProjectName: "IT", Department: "Software"}]
const arr2 = [{Name: "IT", isimplemented: "Yes"}]
我尝试使用以下方法执行相同操作,但未获得所需结果。我如何用JavaScript做到
((arr1.map(data => data.ProjectName)).filter(arr1.map(data => data.ProjectName) === arr2.map(data => data.Name) && isimplemented === "Yes")).length
答案 0 :(得分:0)
Intent mapIntent = new Intent("com.here.maps.DIRECTIONS", Uri.parse(context.getString(R.string.here_map_url_prefix, locationAddress, address)));
mapIntent.addCategory(Intent.CATEGORY_DEFAULT);
context.startActivity(mapIntent);
答案 1 :(得分:0)
您可以为已实施的项目设置一个Set
,然后计算已实施的项目的出现次数。
const
arr1 = [{ ProjectName: "IT", Department: "Software" }],
arr2 = [{ Name: "IT", isimplemented: "Yes" }],
implemented = arr2.reduce((s, { Name, isimplemented }) => isimplemented === 'Yes' ? s.add(Name) : s, new Set),
count = arr1.reduce((c, { ProjectName }) => c + implemented.has(ProjectName), 0);
console.log(count);