challenge-algorithms-v2.0-S.../08-isAnagram/index.js

18 lines
360 B
JavaScript

export function isAnagram(word1, word2) {
let anagram;
if(word1.length !== word2.length) {
anagram = false;
}
let palavra1 = word1.toLowerCase().split("").sort().join("");
let palavra2 = word2.toLowerCase().split("").sort().join("");
if(palavra1 === palavra2) {
anagram = true;
}else {
anagram = false;
}
return anagram;
}