challenge-algorithms-v2.0-i.../09-mostRepeatedChar/index.js

28 lines
411 B
JavaScript
Raw Normal View History

export function mostUsedChar(text) {
2022-10-29 23:19:17 +00:00
// implementar logica aqui
var cont = 0,
maior = 0;
var resp = text.toLowerCase();
var i = 0,
j = 0;
for (i = 0; i < text.length; i++) {
cont = 0;
for (j = 0; j < text.length; j++) {
if (resp[i] == text[j]) {
cont++;
}
}
if (maior < cont) {
maior= cont;
var result= resp[i];
}
}
return result;
}