From 446222dffb3d45e3822cbedc96815fd5d8ec149d Mon Sep 17 00:00:00 2001 From: ednabarboza Date: Fri, 28 Oct 2022 09:16:25 -0300 Subject: [PATCH] feat(home): resolucao da questao 8 --- 08-isAnagram/index.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..9c950e1 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,18 @@ export function isAnagram(word1, word2) { - // implementar logica aqui + let arrayTest = word1.toLowerCase().split('').sort(); + let arrayOriginal = word2.toLowerCase().split('').sort(); + + let palavraTest = arrayTest.toString(); + let palavraOriginal = arrayOriginal.toString(); + + if(arrayTest.length === arrayOriginal.length){ + if(palavraTest === palavraOriginal){ + return true + }else{ + return false + } + }else{ + return false + } } \ No newline at end of file