diff --git a/counting-duplicates/index.js b/counting-duplicates/index.js new file mode 100644 index 0000000..7c88a36 --- /dev/null +++ b/counting-duplicates/index.js @@ -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