//hash tables are used to iterate over an array using a key to compute the array index, instead of using the key as an array index
//for this function i is used as a key to loop through the array
const showDuplicateNo = (array) => { let hashTable = []; let duplicateNo = [];
for (let i = 0; i < array.length; i++) { if (hashTable[array[i].toString()] === undefined) { hashTable[array[i].toString()] = true; }
else { duplicateNo.push(array[i]); }
}
return duplicateNo; }
console.log(showDuplicateNo([2,8,2,8,10,4]))