const fruits = ["apple", "banana", "apple", "orange", "banana", "apple"];
let finalList = fruits.reduce((temp, item)=>{
if(temp[item]){
temp[item]++;
}else{
temp[item]=1;
}
return temp;
}, {});
console.log(finalList);
// output : { apple: 3, banana: 2, orange: 1 }


