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}
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.lo...
● What is React js● What is difference between virtual dom and shallowdom, dom in React js● What is controlled and uncontrolled component inReact js● ...
No comments:
Post a Comment