zählt die Duplikate in einem Array, das für die Schleife verwendet wird
function countDuplicates(arr) {
const counts = {};
for (let i = 0; i < arr.length; i++) {
let element = arr[i];
counts[element] = (counts[element] || 0) + 1;
}
return counts;
}
const arr = ["1", "5", "9", "14", "5", "22", "48", "25", "22", "20", "9", "13"];
console.log(countDuplicates(arr));
JavaScript Biscuit