Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
481 B
1
Indexable
Never
function findDuplicates(arr) {
  var duplicates = {};

  for (var i = 0; i < arr.length; i++) {
    var count = 0;

    for (var j = 0; j < arr.length; j++) {
      if (arr[i] === arr[j]) {
        count++;
      }
    }

    if (count > 1) {
      duplicates[arr[i]] = count;
    }
  }

  for (var key in duplicates) {
    console.log("Number:", key, "Count:", duplicates[key]);
  }
}

// Example usage:
var array = [1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 9];
findDuplicates(array);