I\'m getting an array returned to me and I need to count the rows that have a value in them
I\'ve tried to call arr.length but that gives me the total length of the
Use filter to only capture keys with value, and return the resulting array's length.
var arr = [ { id: '1', '': '' },{ id: '2', '': '' },{ id: '3', '': '' },{ id: '4', '': '' },{ id: '', '': '' },{ id: '', '': '' },{ id: '', '': '' },{ id: '', '': '' },{ id: '', '': '' },{ id: '', '': '' },{ id: '', '': '' },{ id: '', '': '' },{ id: '', '': '' },{ id: '', '': '' },{ id: '', '': '' },{ id: '', '': '' },{ id: '', '': '' },{ id: '', '': '' },{ id: '', '': '' },{ id: '', '': '' },{ id: '', '': '' } ]
var res = arr.filter(val => {
return val.id
})
console.log(res.length)