Edit in JSFiddle

var arr = ["apple","orange","apple","pear"];

function getWordCnt(){
    return arr.reduce(function(prev,next,index){
        console.log("<b>Iteration "+index+"</b>");
        console.log("prev:",prev);
        console.log("next:",next);
        
        prev[next] = ++prev[next] || 1;
        console.log("Passing this to the 'prev' of the next iteration if any:",prev);
        console.log("---------------");
        return prev;
    },{});
}

console.log("<b>Final Object:</b>",getWordCnt());