Can someone help me turn an array of voter objects into a count of how many people voted? I'm just starting to learn JavaScript and feeling confused with the reduce and filter methods. When I run the code, I get undefined @@
function totalVotes(arr) {
let result = arr.filter(function(vote){
return vote.voted === true;
}).reduce(function(total, current){
return total + 1;
},0);}
var voters = [
{name:'Bob' , age: 30, voted: true},
{name:'Jake' , age: 32, voted: true},
{name:'Kate' , age: 25, voted: false},
{name:'Sam' , age: 20, voted: false},
{name:'Phil' , age: 21, voted: true},
{name:'Ed' , age:55, voted:true},
{name:'Tami' , age: 54, voted:true},
{name:'Mary', age: 31, voted: false},
{name:'Becky', age: 43, voted: false},
{name:'Joey', age: 41, voted: true},
{name:'Jeff', age: 30, voted: true},
{name:'Zack', age: 19, voted: false}
];``