Count the Number of Duplicate Characters

Published by Matt in

Create a function that takes a string and returns the number of alphanumeric characters that occur more than once.

Examples

duplicateCount("abcde") ➞ 0

duplicateCount("aabbcde") ➞ 2

duplicateCount("Indivisibilities") ➞ 2

duplicateCount("Aa") ➞ 0
// Case sensitive

Notes

  • Duplicate characters are case sensitive.
  • The input string will contain only alphanumeric characters.
Watch a quick demo on how Edabit works.