javascript - how to get the count of boolean value(if it is true) in array of objects -
i have count of boolean value(if true) in array of objects. json structure given below:
[ { "id": 5, "name": "a", "select": true }, { "id": 3, "name": "b", "select": false }, { "id": 2, "name": "x", "select": true }, { "id": 1, "name": "y", "select": false } ]
you can using array.prototype.filter()
try this
console.log(data.filter((x,i) => { return x.select; }).length)
Comments
Post a Comment