feat: resolucao funcao isAnagram

This commit is contained in:
Guilherme de Camargo Barbosa 2022-10-29 18:55:15 -03:00
parent 3e2337919c
commit 27c0c1f894

View File

@ -1,4 +1,20 @@
export function isAnagram(word1, word2) {
// implementar logica aqui
}
const worldUp1 = /[A-Z]/.test(word1);
const worldUp2 = /[A-Z]/.test(word2);
if(worldUp1 || worldUp2) {
const str1 = word1.toLowerCase()
const str2 = word1.toLowerCase()
const isAnagramStr = ''+[...str1].sort()==[...str2].sort()
return isAnagramStr
} else {
const isAnagramStr = ''+[...word1].sort()==[...word2].sort()
return isAnagramStr
}
}
isAnagram('roma', 'amor') // true