From 712c72d45c3ae31aa3ac86ccb7171b74344546b9 Mon Sep 17 00:00:00 2001 From: Ramon Dias Ferreira Date: Tue, 1 Nov 2022 22:31:51 -0300 Subject: [PATCH] =?UTF-8?q?feat(isAnagram):=20toLowerCase=20utilizado=20pa?= =?UTF-8?q?ra=20retornar=20as=20palavras=20todas=20minusculas=20para=20ver?= =?UTF-8?q?ifica=C3=A7=C3=A3o,=20if=20para=20condicional=20negativa,=20spl?= =?UTF-8?q?it=20para=20ordenar=20a=20string,=20join=20para=20retornar=20a?= =?UTF-8?q?=20string=20junta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 08-isAnagram/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..1361c11 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,13 @@ export function isAnagram(word1, word2) { // implementar logica aqui - -} \ No newline at end of file + let word1Lower = word1.toLowerCase() + let word2Lower = word2.toLowerCase() + if (word1Lower.length !== word2Lower.length) { + return false; +} +var string1 = word1Lower.split('').sort().join(''); +var string2 = word2Lower.split('').sort().join(''); + +var result = (string1 === string2); +return result; +}