forked from M3-Academy/challenge-algorithms-v2.0
Feat:Finalizado isAnagram
This commit is contained in:
parent
0ae3211bdc
commit
d98388c5d2
@ -1,4 +1,20 @@
|
||||
export function isAnagram(word1, word2) {
|
||||
// implementar logica aqui
|
||||
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user