diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..3c03f12 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,19 @@ export function isAnagram(word1, word2) { // implementar logica aqui - -} \ No newline at end of file + let par_1 = word1.toLowerCase().split("").sort(); + let par_2 = word2.toLowerCase().split("").sort(); + let final; + if (par_1.length != par_2.length) { + final = "false"; + } else { + for (i in par_1) { + if (par_1[i] != par_2[i]) { + final = "false"; + break; + } else { + final = "true"; + } + } + } + return final; +}