From afe4d17414899d68000e3eb729985b549c184518 Mon Sep 17 00:00:00 2001 From: Eliaz Bobadilla Date: Sun, 27 Jun 2021 15:25:32 -0500 Subject: [PATCH] :memo: Add Badges --- 04-arithmetic/mediana.js | 23 ++++++++++------------- README.md | 5 +++++ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/04-arithmetic/mediana.js b/04-arithmetic/mediana.js index 5c0cd1d..4f8e38c 100644 --- a/04-arithmetic/mediana.js +++ b/04-arithmetic/mediana.js @@ -5,8 +5,6 @@ const calcularMediaAritmetica = (arr) => (valorAcumulado = 0, nuevoElemento) => valorAcumulado + nuevoElemento ) / arr.length; -const mitadLista1 = NUMBERS.length / 2; - function isEven(n) { if (!n % 2 === 0) { return true; @@ -14,17 +12,16 @@ function isEven(n) { return false; } -let mediana; - -if (isEven(NUMBERS.length)) { - const elemento1 = NUMBERS[mitadLista1 - 1]; - const elemento2 = NUMBERS[mitadLista1]; +function main() { + if (isEven(NUMBERS.length)) { + const promedioElemento1y2 = calcularMediaAritmetica([ + NUMBERS[NUMBERS.length / 2 - 1], + NUMBERS.length / 2, + ]); - const promedioElemento1y2 = calcularMediaAritmetica([elemento1, elemento2]); - - mediana = promedioElemento1y2; -} else { - mediana = NUMBERS[mitadLista1]; + return promedioElemento1y2; + } + return NUMBERS[NUMBERS.length / 2]; } -console.log(mediana); +console.log(main()); diff --git a/README.md b/README.md index f1dd8ce..9f8045b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # Curso Práctico de JavaScript +[![GitMoji](https://img.shields.io/badge/gitmoji-%20😜-FFDD67.svg)](https://gitmoji.dev) +[![Language Grade](https://img.shields.io/lgtm/grade/javascript/g/UltiRequiem/oop-js-platzi.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/UltiRequiem/oop-js-platzi/context:javascript) +[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) +[![Lines Of Code](https://img.shields.io/tokei/lines/github.com/UltiRequiem/oop-js-platzi?color=blue&label=Total%20Lines)](https://github.com/UltiRequiem/oop-js-platzi) + Notas y código del curso. ![Wall](./img/wall.jpg)