2022-10-27 15:07:13 +00:00
|
|
|
export function isAnagram(word1, word2) {
|
|
|
|
// implementar logica aqui
|
2022-10-29 00:44:37 +00:00
|
|
|
const anagrama = word1.toLowerCase().split('');
|
|
|
|
const palavra = word2.toLowerCase().split('');
|
|
|
|
palavra.sort((a, b) => {
|
|
|
|
return a.localeCompare(b);
|
|
|
|
})
|
|
|
|
anagrama.sort((a, b) => {
|
|
|
|
return a.localeCompare(b);
|
|
|
|
})
|
|
|
|
if( anagrama.length > palavra.length){
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
for(let i = 0;i < word2.length; i++){
|
|
|
|
if(anagrama[i] !== palavra[i]){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2022-10-27 15:07:13 +00:00
|
|
|
}
|