diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..3a836d8 --- /dev/null +++ b/.vscode/launch.json @@ -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}" + } + ] +} \ No newline at end of file diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 6ced933..80017e3 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,13 +1,13 @@ export function fibonacci(value) { // implementar logica aqui - let soma = 0; - let anterior = 0; - let proximo = 1; + let soma = 0; + let anterior = 0; + let proximo = 1; - for (let i = 0; i < value; i++) { - soma = anterior + proximo; - anterior = proximo; - proximo = soma; - } - return anterior; -} + for (let i = 0; i < value; i++) { + soma = anterior + proximo; + anterior = proximo; + proximo = soma; + } + return anterior; +} \ No newline at end of file diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..54c1645 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,26 @@ export function mostUsedChar(text) { - // implementar logica aqui - return "" + let arr = []; + 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 } \ No newline at end of file