From 39515dd0474ab5dd20e60e79adad467fb107abb9 Mon Sep 17 00:00:00 2001 From: Matheus Date: Wed, 2 Nov 2022 12:42:08 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20cria=C3=A7=C3=A3o=20da=20resposat=20do?= =?UTF-8?q?=2008-isAnagram?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 08-isAnagram/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..e06ff3c 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,14 @@ export function isAnagram(word1, word2) { // implementar logica aqui - + if(word1 === word2) { + return true; + } else if (word1.length !== word2.length) { + return false; + } else { + var str1 = word1.toLowerCase().split("").sort().join(""); + var str2 = word2.toLowerCase().split("").sort().join(""); + var result = (str1 == str2); + return result; + } + } \ No newline at end of file