forked from M3-Academy/challenge-algorithms-v2.0
feat(09-mostrepeatedchar):completead ninth challenge
This commit is contained in:
parent
c6f6df9c59
commit
3c50e566ab
@ -1,4 +1,16 @@
|
||||
export function mostUsedChar(text) {
|
||||
// implementar logica aqui
|
||||
return ""
|
||||
let caractercount = 0; let caractersave = {}; let caracter = " ";
|
||||
text.split("").forEach((repetido) => {
|
||||
if(caractersave[repetido]){
|
||||
caractersave[repetido] += 1;
|
||||
} else{
|
||||
caractersave[repetido] = 1;
|
||||
}
|
||||
if(caractersave[repetido] > caractercount){
|
||||
caractercount = caractersave[repetido];
|
||||
caracter = repetido;
|
||||
}
|
||||
});
|
||||
return caracter;
|
||||
}
|
Loading…
Reference in New Issue
Block a user