我有一个x可以具有以下值的数组:
0: {status: "completed", count: 2}
1: {status: "pending", count: 3}
现在,如果状态匹配,pending那么我想捕获相应的值count。
我写了以下代码:
if (x?.length) {
PendingCount = x[1].count;
completedCount = x[0].count;
}
这并不总是给出所需的输出,因为pending状态不一定总是在x[0]
潇潇雨雨
森栏
繁星点点滴滴
蝴蝶刀刀
相关分类