forked from M3-Academy/challenge-algorithms-v2.0
Merge branch 'feature/09-mostRepeatedChar' into developer
This commit is contained in:
commit
1c2a3ae877
@ -1,4 +1,22 @@
|
||||
export function mostUsedChar(text) {
|
||||
// implementar logica aqui
|
||||
return ""
|
||||
const boxChar = {};
|
||||
let max = 0;
|
||||
let result = '';
|
||||
|
||||
for(let char of text){
|
||||
if(boxChar[char]){
|
||||
boxChar[char]++;
|
||||
}else{
|
||||
boxChar[char] = 1;
|
||||
}
|
||||
}
|
||||
for(let char in boxChar){
|
||||
if(boxChar[char] > max){
|
||||
max = boxChar[char];
|
||||
result = char;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
Loading…
Reference in New Issue
Block a user