challenge-algorithms-v2.0-a.../08-isAnagram/index.js
2022-11-02 15:00:01 -03:00

11 lines
228 B
JavaScript

export function isAnagram(word1, word2) {
const retorne = (word) =>
word
.toLowerCase()
.replace(/[^a-z0-9]/gi, "")
.split("")
.sort()
.join("");
return retorne(word1) === retorne(word2);
}