Menu
I have an array and inside a bunch of records which are objects.
Each record object has a key “published” with a value of 0 or 1 and I am simply trying to get a count of all the ones published so if 5 are published I want to return a value of 5.
I have this:
“`
const total = this.records
.map(function(b) {
return b.published
})
.reduce(function(p, c) {
return p + c
})
But it still says 7 ( there are 7 records in total for the sake of the question, 3 published, 4 not)
When I need to get 4 as total published.
Can anyone assist me in this issue.
What am I doing wrong?
Thanks,
Dave