React Js
7/21/2023 12:17:00 am
Write a program to find element occurence from array in React js
const arr = [1,1,2,3,1,4]
const count = {};
for (const element of arr) {
if (count[element]) {
count[element] += 1;
} else {
count[element] = 1;
}
}
console.log(count); // 👉 {1: 3, 2: 1, 3: 2}
