development #13

Merged
Rafael_Sampaio_de_Oliveira merged 22 commits from development into master 2022-11-01 16:32:59 +00:00
Showing only changes of commit c7a7572841 - Show all commits

View File

@ -1,4 +1,17 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
}
// implementar logica aqui
let arr = text.toLowerCase().split("").sort();
let mostRepeated = null;
let moreOccurrences = -1;
let count = 1;
for (let i = 1; i <= arr.length; i++) {
if (i < arr.length && arr[i] === arr[i - count]) {
count++;
} else if (count > moreOccurrences) {
mostRepeated = arr[i - 1];
moreOccurrences = count;
}
}
return `${mostRepeated}`;
}