diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..88a269c 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,20 @@ export function isAnagram(word1, word2) { // implementar logica aqui - -} \ No newline at end of file + + 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 \ No newline at end of file