I have several objects inside of an array in Javascript. The object looks like this:
model: [
{
category: 'Media',
value: '',
checked: false
},
{
category: 'Entertainment',
value: '',
checked: false
},
{
category: 'Music',
value: '',
checked: false
},
{
category: 'Theater',
value: '',
checked: false
}
]
I want to loop through this array of objects, and tally up the number of checked: true values there are. If all of them equal true, I want to run a function. How do I go about seeing if all of the checked values are equal to true?
model.every(a=>a.checked).model.every(function (item) { return item.checked })for non-ES6 browsers