Skip to content

Latest commit

 

History

History
16 lines (14 loc) · 287 Bytes

is_anagram.md

File metadata and controls

16 lines (14 loc) · 287 Bytes

Is anagram

const isAnagram = (str1, str2) => {
  const normalize = str =>
    str
      .toLowerCase()
      .replace(/[^a-z0-9]/gi, '')
      .split('')
      .sort()
      .join('');
  return normalize(str1) === normalize(str2);
};

isAnagram('iceman', 'cinema'); // true