forked from M3-Academy/challenge-algorithms-v2.0
feat: Algoritmo 09-mostRepeatedChar - finalizado
This commit is contained in:
parent
4627081856
commit
6d4c4c3b53
@ -1,4 +1,26 @@
|
|||||||
export function mostUsedChar(text) {
|
export function mostUsedChar(text) {
|
||||||
// implementar logica aqui
|
// 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;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user