Counting Duplicates

This commit is contained in:
2019-12-10 04:12:58 +01:00
parent 012d22a6d7
commit 1eecf8d16f

View File

@@ -0,0 +1,8 @@
// https://www.codewars.com/kata/counting-duplicates/javascript
function duplicateCount(text) {
const m = text.toLowerCase().match(/[a-z0-9]/g) || [];
const cnt = new Map();
m.map(c => cnt.set(c, (cnt.get(c) || 0) + 1));
return [...cnt].filter(([k,v])=>1<v).length;
}