What's missing in this code?
getNumberPairs('5 1 2 3 4 5'); // 0
getNumberPairs('7 1 2 2 3 4 3 4'); // 3
getNumberPairs('6 1 2 2 3 4 5'); // 1
getNumberPairs('7 1 2 2 3 3 3 4'); // 2
getNumberPairs('8 1 1 2 2 3 3 3 3'); // 4
function getNumberPairs(input) {
let values = input.split(' ').map(Number);
let numbers = values.
(1);
let frequency = {};
for (let num of numbers) {
frequency[num] = (frequency[num] || 0) + 1;
}
let pairs = 0;
for (let count of
(frequency)) {
pairs += Math.floor(
);
}
return pairs;
}
Type or select from these options