find sum of Boolean values JavaScript object array

前端 未结 4 953
天命终不由人
天命终不由人 2020-12-31 07:34

Hi i am trying to find the sum of Boolean values in the object array in JavaScript

My json like be

var myoBj = [{
  \"id\": 1,
  \"day\": 1,
  \"st         


        
4条回答
  •  醉酒成梦
    2020-12-31 08:05

    You could use Array.some with predicate a => !a.status or Array.every with predicate a => a.status.

    Either of them will short-circuit if you find a mismatch, while Array.reduce will not.

提交回复
热议问题