forked from M3-Academy/challenge-algorithms-v2.0
feature/algoritmo #1
@ -1,4 +1,20 @@
|
||||
export function mostUsedChar(text) {
|
||||
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 ""
|
||||
return maxChar;
|
||||
}
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue
Block a user