I have an array where each index with the same name should be counted in the object. Please check the example and result below. I'm trying to figure out a few things:
const obj = {
viktor: ["apple", "grape", "orange", "apple", "banana"],
kate: ["grape", "orange", "apple", "grape", "banana"]
};
function calc(a) {
}
console.log(calc(obj));
// result of calc method should be equal to
// {
// viktor: {
// apple: 2,
// grape: 1,
// orange: 1,
// banana: 1
// },
// kate: {
// apple: 1,
// grape: 2,
// orange: 1,
// banana: 1
// }
// }