forked from M3-Academy/challenge-algorithms-v2.0
feat: resolve funcão isAnagram
This commit is contained in:
parent
1ed22cb2fa
commit
b6ab1f4f3a
@ -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;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user