From edd318c580e61851d10ac9ab8a6e812e2e8da0fb Mon Sep 17 00:00:00 2001 From: "Henrique@Martins" Date: Mon, 31 Oct 2022 07:51:30 -0300 Subject: [PATCH] feat(all-script)otimiza o codigo --- 01-greeting/index.js | 2 +- 02-triangleArea/index.js | 6 +++--- 03-maxValue/index.js | 12 ++++++------ 04-fibonacci/index.js | 12 ++++++------ 05-isPrime/index.js | 18 ++++++++--------- 06-sum/index.js | 8 ++++---- 07-sumEven/index.js | 10 +++++----- 09-mostRepeatedChar/index.js | 38 +++++++++++++++++++----------------- 8 files changed, 54 insertions(+), 52 deletions(-) diff --git a/01-greeting/index.js b/01-greeting/index.js index 8456c21..5c0279c 100644 --- a/01-greeting/index.js +++ b/01-greeting/index.js @@ -1,4 +1,4 @@ export function greet(name) { // implementar logica aqui -return `Hello ${name}`; + return `Hello ${name}`; } diff --git a/02-triangleArea/index.js b/02-triangleArea/index.js index 65f4b7e..00121cc 100644 --- a/02-triangleArea/index.js +++ b/02-triangleArea/index.js @@ -1,4 +1,4 @@ -export function triangleArea(base, height) { +export function triangleArea(base, height) { // your code here - return (base * height) / 2 -} \ No newline at end of file + return (base * height) / 2; +} diff --git a/03-maxValue/index.js b/03-maxValue/index.js index 9453405..9b1b79f 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,8 +1,8 @@ export function maxValue(values) { // implementar logica aqui - if(values.length === 0){ - return values = 0 - } else{ - return Math.max.apply(null, values); - } -} \ No newline at end of file + if (values.length === 0) { + return (values = 0); + } else { + return Math.max.apply(null, values); + } +} diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 00aae04..4f66087 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,8 +1,8 @@ export function fibonacci(value) { // implementar logica aqui - if (value === 0 || value === 1){ - return value -}else{ - return fibonacci(value - 1) + fibonacci(value - 2) - } -} \ No newline at end of file + if (value === 0 || value === 1) { + return value; + } else { + return fibonacci(value - 1) + fibonacci(value - 2); + } +} diff --git a/05-isPrime/index.js b/05-isPrime/index.js index 3ac2e58..6c3fe87 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,12 +1,12 @@ export function isPrime(value) { // implementar logica aqui - let primo = true - for(let i = 2; i < value; i++){ - if(value % i === 0){ - primo = false - break - } - } + let primo = true; + for (let i = 2; i < value; i++) { + if (value % i === 0) { + primo = false; + break; + } + } - return primo -} \ No newline at end of file + return primo; +} diff --git a/06-sum/index.js b/06-sum/index.js index ccc7113..98d78ae 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,8 +1,8 @@ export function sum(values) { // implementar logica aqui - let soma = 0 - for (let i = 0; i < values.length; i++){ - soma += values[i] + let soma = 0; + for (let i = 0; i < values.length; i++) { + soma += values[i]; } - return soma + return soma; } diff --git a/07-sumEven/index.js b/07-sumEven/index.js index 55d7f16..98cb1ac 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,10 +1,10 @@ export function sumEven(value) { // implementar logica aqui let soma = 0; - for(let i = 0; i < value.length; i++){ - if(value[i] % 2 === 0){ - soma += value[i]; - } + for (let i = 0; i < value.length; i++) { + if (value[i] % 2 === 0) { + soma += value[i]; + } } return soma; -} \ No newline at end of file +} diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index c51b3fa..a986cfe 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,21 +1,23 @@ export function mostUsedChar(text) { - // implementar logica aqui - let cont=0, maior=0 + // implementar logica aqui + let cont = 0, + maior = 0; - let resp = text.toLowerCase() + let resp = text.toLowerCase(); - let i = 0, j = 0 - for(i = 0; i < text.length; i++){ - cont = 0 - for(j = 0; j < text.length; j++){ - if(resp[i] == text[j]){ - cont++ - } - } - if(maior < cont){ - maior = cont - var resposta = resp[i] - } - } - return resposta -} \ No newline at end of file + let i = 0, + j = 0; + for (i = 0; i < text.length; i++) { + cont = 0; + for (j = 0; j < text.length; j++) { + if (resp[i] == text[j]) { + cont++; + } + } + if (maior < cont) { + maior = cont; + var resposta = resp[i]; + } + } + return resposta; +}