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

14 lines
370 B
JavaScript
Raw Normal View History

export function isAnagram(word1, word2) {
// implementar logica aqui
if(word1 === word2) {
return true;
} else if (word1.length !== word2.length) {
return false;
} else {
var str1 = word1.toLowerCase().split("").sort().join("");
var str2 = word2.toLowerCase().split("").sort().join("");
var result = (str1 == str2);
return result;
}
}