Counting Duplicates
This commit is contained in:
8
counting-duplicates/index.js
Normal file
8
counting-duplicates/index.js
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user