From 5c45023156f3613e97f3243c6b238720d855c2b1 Mon Sep 17 00:00:00 2001 From: ThiagoDuutra Date: Fri, 28 Oct 2022 17:04:12 -0300 Subject: [PATCH] feat: Resolvido questao isAnagram --- 08-isAnagram/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..a5cbc85 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,11 @@ export function isAnagram(word1, word2) { // implementar logica aqui - -} \ No newline at end of file + //1º => Ver se as strings tem a mesma quantidade de letras + if (word1.length !== word2.length) { + return false; + } + //2º => Criar duas variáveis para as novas strings + let newTest = word1.toLowerCase().split("").sort().join(""); + let newOriginal = word2.toLowerCase().split("").sort().join(""); + return newTest === newOriginal; +}