From 6f51a812184777939761e4400313b10e80cc32c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Gabriel?= <=> Date: Sun, 30 Oct 2022 09:12:36 -0300 Subject: [PATCH] =?UTF-8?q?Fix:=20Organiza=C3=A7=C3=A3o=20do=20c=C3=B3digo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 08-isAnagram/index.js | 7 ++----- 09-mostRepeatedChar/index.js | 4 ++-- 10-longestWords/index.js | 15 +++++++-------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 70059cb..31fd2d0 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,8 +1,7 @@ export function isAnagram(word1, word2) { let teste, original, cont1 = 0, cont2 = 0; - - teste = word1.split(""); - original = word2.split(""); + teste = word1.split("").sort(); + original = word2.split("").sort(); if (teste.length === original.length) { for (let i = 0; i < teste.length; i++) { @@ -18,7 +17,6 @@ export function isAnagram(word1, word2) { cont2++; } } - if (cont1 === cont2) { return true; } else { @@ -28,5 +26,4 @@ export function isAnagram(word1, word2) { } else { return false } - } \ No newline at end of file diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index 1c0e6bb..9a48d77 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -6,12 +6,12 @@ export function mostUsedChar(text) { cont = 0; for (let j = 0; j < texto.length; j++) { if (texto[i].toUpperCase() === texto[j].toUpperCase()) { - cont++ + cont++; } } if (cont >= contador) { contador = cont; - finalVlue = texto[i] + finalVlue = texto[i]; } } return finalVlue; diff --git a/10-longestWords/index.js b/10-longestWords/index.js index 97cd6a0..829bca4 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,25 +1,24 @@ export function longestWords(words) { - let arr = []; + let arr, arr1; let cont = 0; let primeiro = true; - let arr1; for (let i = 0; i < words.length; i++) { if (primeiro === true) { - cont = words[i].length + cont = words[i].length; arr = " " + words[i]; primeiro = false; } else if (words[i].length > cont) { - cont = words[i].length + cont = words[i].length; arr = " " + words[i]; - + } else if (words[i].length === cont) { - cont = words[i].length + cont = words[i].length; arr += " " + words[i]; } } - arr1 = arr.split(" ") - arr1.shift() + arr1 = arr.split(" "); + arr1.shift(); return (arr1); } \ No newline at end of file