Is Anagram

    0

    0

    Giovanny Gongora

    Codiga's TypeScript Recipes

    Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation, and special characters).

    const isAnagram = (str1: string, str2: string) => {
      const normalize = (str: string) =>
        str
          .toLowerCase()
          .replace(/[^a-z0-9]/gi, '')
          .split('')
          .sort()
          .join('');
      return normalize(str1) === normalize(str2);
    };
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.