forked from M3-Academy/challenge-algorithms-v2.0
feat(09-mostRepeatedChar): Cria a função
This commit is contained in:
parent
e3706d5771
commit
d2ea761b4f
@ -1,4 +1,19 @@
|
||||
export function mostUsedChar(text) {
|
||||
// implementar logica aqui
|
||||
return ""
|
||||
let arrChar;
|
||||
arrChar = text.split('');
|
||||
let countCharMax = 1;
|
||||
let countChar = 0;
|
||||
let char;
|
||||
for (let i=0; i<arrChar.length; i++)
|
||||
{
|
||||
for (let j=i; j<arrChar.length; j++) {
|
||||
if (arrChar[i] == arrChar[j])
|
||||
countChar++;
|
||||
if (countCharMax<countChar) {
|
||||
countCharMax=countChar;
|
||||
char = arrChar[i];
|
||||
}
|
||||
}
|
||||
countChar = 0;
|
||||
} return char;
|
||||
}
|
Loading…
Reference in New Issue
Block a user