From 29ec105dd312ba1f1fee6694cbbf8ca2448392eb Mon Sep 17 00:00:00 2001 From: HenriqueSSan Date: Thu, 27 Oct 2022 21:22:41 -0300 Subject: [PATCH] feat(challenge-8): completed challenge --- 08-isAnagram/index.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..4648e7b 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,18 @@ export function isAnagram(word1, word2) { // implementar logica aqui - -} \ No newline at end of file + if (!word1 || !word2) return { error: 'Not Found Words' }; + + function toLowerCase(word) { + return word.toLowerCase(); + } + + function toSortWord(word) { + return word.split('').sort().join(''); + } + + function toAnalyzing(word){ + return toSortWord(toLowerCase(word)) + } + + return toAnalyzing(word1) === toAnalyzing(word2) +}