From 10ef9194b8fa2caf169e572e4941600dc23d0af7 Mon Sep 17 00:00:00 2001 From: JoseGregorioMataRodriguez Date: Sat, 29 Oct 2022 18:06:56 -0200 Subject: [PATCH] =?UTF-8?q?fix:=20optimizac=C3=A3o=20de=20isAnagram=20e=20?= =?UTF-8?q?maxValue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 03-maxValue/index.js | 18 +++++++++--------- 08-isAnagram/index.js | 33 ++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index 8571f7c..b1262bd 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,13 +1,13 @@ export function maxValue(values) { // implementar logica aqui let numeromaior = 0; - if (values[0] < numeromaior) - numeromaior = values[0]; - let i = 0; - for (i = 0; i < values.length; i++){ - if (numeromaior < values[i]){ - numeromaior = values[i]; - } - } - return numeromaior; + if (values[0] < numeromaior) + numeromaior = values[0]; + let i = 0; + for (i = 0; i < values.length; i++){ + if (numeromaior < values[i]){ + numeromaior = values[i]; + } + } + return numeromaior; } \ No newline at end of file diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index d47e20b..c748d45 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,22 +1,25 @@ export function isAnagram(word1, word2) { // implementar logica aqui + if ((!word1) || (!word2)) + return false; if (word1 != word2){ if (word1.lenght == word2.lenght){ - word1 = word1.toLowerCase(); - word2 = word2.toLowerCase(); - let teste = word1.split(''); - let origin = word2.split(''); - teste = teste.sort(); - origin = origin.sort(); - teste = teste.join(); - origin = origin.join(); - if (teste == origin) - return true; - else - return false; + word1 = word1.toLowerCase(); + word2 = word2.toLowerCase(); + let teste = word1.split(''); + let origin = word2.split(''); + teste = teste.sort(); + origin = origin.sort(); + teste = teste.join(); + origin = origin.join(); + if (teste == origin) + return true; + else + return false; } - else return false; -} -else return false; + else + return false; + } + else return false; } \ No newline at end of file -- 2.34.1