feat: resolve funcão isAnagram

This commit is contained in:
José Gregorio Mata Rodríguez 2022-10-29 01:47:17 -02:00
parent 1ed22cb2fa
commit b6ab1f4f3a

View File

@ -1,4 +1,22 @@
export function isAnagram(word1, word2) {
// implementar logica aqui
if (word1 != word2){
if (word1.lenght == word2.lenght){
word1 = word1.toLowerCase();
word2 = word2.toLowerCase();
let teste = word1.split('');
let origin = word2.split('');
teste = teste.sort();
origin = origin.sort();
teste = teste.join();
origin = origin.join();
if (teste == origin)
return true;
else
return false;
}
else return false;
}
else return false;
}