forked from M3-Academy/challenge-algorithms-v2.0
11 lines
232 B
JavaScript
11 lines
232 B
JavaScript
export function isAnagram(word1, word2) {
|
|
const normalize = (str) =>
|
|
str
|
|
.toLowerCase()
|
|
.replace(/[^a-z0-9]/gi, "")
|
|
.split("")
|
|
.sort()
|
|
.join("");
|
|
return normalize(word1) === normalize(word2);
|
|
}
|