function duplicateCount(text){ //... const lowercase = text.toLowerCase() const arr = lowercase.split('') arr.sort() let answer = 0 for (i=0; i<arr.length; i++) { if (arr[i]===arr[i+1]){ const letter =arr[i] while (arr[i+1] === letter) { i++ } answer ++ } } return answer }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter