2022-10-27 15:07:13 +00:00
|
|
|
export function isAnagram(word1, word2) {
|
|
|
|
// implementar logica aqui
|
2022-10-29 05:05:24 +00:00
|
|
|
|
|
|
|
const word2Arr = word2.toLowerCase().split('');
|
|
|
|
|
|
|
|
for(let i = 0; i < word1.length; i++) {
|
|
|
|
|
|
|
|
const index = word2Arr.indexOf(word1.toLowerCase()[i]);
|
|
|
|
|
|
|
|
if(index === -1) return false;
|
|
|
|
word2Arr.splice(index, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return !word2Arr.length;
|
2022-10-27 15:07:13 +00:00
|
|
|
|
|
|
|
}
|