Edit in JSFiddle

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

function getWordCnt(){
    var obj = {};
    
    for(var i= 0, l = arr.length; i< l; i++){
        var item = arr[i];
        obj[item] = (obj[item] +1 ) || 1;
    }
    
    return obj;
}

console.log(getWordCnt());