Fix: Organização do código

This commit is contained in:
Vinícius Gabriel 2022-10-30 09:12:36 -03:00
parent 77e39ddda4
commit 6f51a81218
3 changed files with 11 additions and 15 deletions

View File

@ -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
}
}

View File

@ -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;

View File

@ -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);
}