feature/algoritmo #1

Merged
PatrickReisSantos merged 10 commits from feature/algoritmo into master 2022-11-02 16:06:18 +00:00
2 changed files with 35 additions and 6 deletions
Showing only changes of commit aa43fe4a02 - Show all commits

View File

@ -1,4 +1,20 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
let freqCounter = [];
let textStr = text.toLowerCase();
for (let char of textStr) {
freqCounter[char] = freqCounter[char] + 1 || 1;
}
let maxCount = 0;
let maxChar = null;
for (let key in freqCounter) {
if (freqCounter[key] > maxCount) {
maxCount = freqCounter[key];
maxChar = key;
}
}
// implementar logica aqui
return maxChar;
}

View File

@ -1,4 +1,17 @@
export function longestWords(words) {
// implementar logica aqui
let longestWord = "";
let longestWordsArray = [];
for (let i = 0; i < words.length; i++) {
if (words[i].length >= longestWord.length) {
longestWord = words[i];
}
}
for (let i = 0; i < words.length; i++) {
if (words[i].length == longestWord.length) {
longestWordsArray.push(words[i]);
}
}
return longestWordsArray;
// implementar logica aqui
}