forked from M3-Academy/challenge-algorithms-v2.0
desafio 09 concluido
This commit is contained in:
parent
35269078e8
commit
70fd2a1c47
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
// Use o IntelliSense para saber mais sobre os atributos possíveis.
|
||||||
|
// Focalizar para exibir as descrições dos atributos existentes.
|
||||||
|
// Para obter mais informações, acesse: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "chrome",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Launch Chrome against localhost",
|
||||||
|
"url": "http://localhost:8080",
|
||||||
|
"webRoot": "${workspaceFolder}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -1,4 +1,26 @@
|
|||||||
export function mostUsedChar(text) {
|
export function mostUsedChar(text) {
|
||||||
// implementar logica aqui
|
let arr = [];
|
||||||
return ""
|
for (let i = 0; i < text.length; i++) {
|
||||||
|
let letra = text[i]
|
||||||
|
if(arr[letra]) {
|
||||||
|
arr[letra]++
|
||||||
|
} else {
|
||||||
|
arr[letra] = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnValue(text, arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
function returnValue(text, arr) {
|
||||||
|
let maiorValor = 0
|
||||||
|
let letraMaiorValor = ""
|
||||||
|
for (let i = 0; i < text.length; i++) {
|
||||||
|
let letra = text[i]
|
||||||
|
let qtdLetra = arr[letra]
|
||||||
|
if(qtdLetra > maiorValor) {
|
||||||
|
maiorValor = qtdLetra
|
||||||
|
letraMaiorValor = letra
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return letraMaiorValor
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user