September 23rd, 2024
What's missing in this code?
func([3, 2, 3, 1, 2, 3]); // 3
func([1, 1, 2, 2, 2, 4, 4]); // 0
func([2, 1, 1, 2, 3, 3, 3]); // 2
func([5, 2, 5, 2, 5, 5]); // 1
func([1]); // 1
func([2]); // 0
func([1, 1, 1, 3, 3, 3, 3]); // 0
function func(arr) {
const map = {};
for (let num of arr) {
map[num] = (
) + 1;
}
let matchCount = 0;
for (let [num, count] of
) {
if (
=== count) {
matchCount++;
}
}
return matchCount;
}
Type or select from these options