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

23 lines
443 B
JavaScript

export function mostUsedChar(text) {
// implementar logica aqui
let caracMax
let qtdd = 0
let qtdd2 = 0
for(let i = 0; i < text.length; i++){
for(let j = 0; j < text.length; j++){
if(text[i] == text[j]){
qtdd2 = qtdd2 + 1
}
}
if(qtdd2 > qtdd){
caracMax = text[i]
qtdd = qtdd2
}
qtdd2 = 0
}
return caracMax
}