Count the Number of Special Characters I

EasyHash TableString

Solution

export function numberOfSpecialChars(word: string): number {
  const set = new Set(word);
  const alphabets = 'abcdefghijklmnopqrstuvwxyz';
 
  let answer = 0;
  for (const char of alphabets) {
    if (set.has(char) && set.has(char.toUpperCase())) {
      answer += 1;
    }
  }
  return answer;
}