feat(isAnagram): Finaliza algoritmo
This commit is contained in:
parent
c26a87b843
commit
f748d31ad5
@ -1,4 +1,16 @@
|
||||
export function isAnagram(word1, word2) {
|
||||
// implementar logica aqui
|
||||
|
||||
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;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user