我正在尝试计算如下所示的javascript对象中的总数
1: Array(37)
0:
campaign: Array(1)
0: {contentful_id: "4liiuveKdiy0kwS06Eoewu"}
length: 1
__proto__: Array(0)
__proto__: Object
1: {campaign: Array(1)}
2: {campaign: Array(1)}
3: {campaign: Array(1)}
4: {campaign: Array(1)}
5: {campaign: Array(1)}
6: {campaign: Array(1)}
7: {campaign: Array(1)}
8: {campaign: null}
9:
campaign: Array(1)
0: {contentful_id: "5q3ynEiM8MuyMAE0EkEwES"}
length: 1
__proto__: Array(0)
__proto__: Object
10: {campaign: null}
我正在尝试计算contentful_id = 4liiuveKdiy0kwS06Eoewu的总记录
let counter = 0;
this.props.data.edges.map((edge, index) => {
if(edge.node.items[index].campaign[0].contentful_id == '4liiuveKdiy0kwS06Eoewu') {
counter++
}
})
它给了我错误的计数,包括'4liiuveKdiy0kwS06Eoewu'以外的contentful_id