feat: Algoritmo 09-mostRepeatedChar - finalizado

This commit is contained in:
José Carlos Lins 2022-10-27 20:44:23 -03:00
parent 4627081856
commit 6d4c4c3b53

View File

@ -1,4 +1,26 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
let newStr = text.replace(' ', '').split('');
let count = 0;
let countControl = 0;
let strRepeat = '';
for(let i = 0; i < newStr.length; i++){
for(let j = 0; j < newStr.length; j++){
if(newStr[i] === newStr[j]){
count++;
}
}
if(count > countControl){
strRepeat = newStr[i];
countControl = count;
}
count = 0;
}
return strRepeat;
}