From e3706d57712d3c4570d3ca366c112798f0399192 Mon Sep 17 00:00:00 2001 From: LeonardoPereiraRocha Date: Wed, 2 Nov 2022 14:23:55 -0300 Subject: [PATCH] =?UTF-8?q?feat(08-isAnagram):=20Cria=20a=20fun=C3=A7?= =?UTF-8?q?=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 04-fibonacci/index.js | 1 + 08-isAnagram/index.js | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index e7b1ce3..c0602cd 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,5 @@ export function fibonacci(value) { + // let previous = 0; let sum = 0; let next = 1; diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..eb064c3 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,19 @@ export function isAnagram(word1, word2) { - // implementar logica aqui - + let testWord1; + let testWord2; + + if (word1.length !== word2.length) { + return false; + } + + + testWord1 = word1.toLowerCase('').split('').sort().join(''); + testWord2 = word2.toLowerCase('').split('').sort().join(''); + + if (testWord1 === testWord2) { + return true; + } + + return false; + } \ No newline at end of file