Skip to content

Commit

Permalink
📝 Add Badges
Browse files Browse the repository at this point in the history
  • Loading branch information
UltiRequiem committed Jun 27, 2021
1 parent a520088 commit afe4d17
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
23 changes: 10 additions & 13 deletions 04-arithmetic/mediana.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,23 @@ const calcularMediaAritmetica = (arr) =>
(valorAcumulado = 0, nuevoElemento) => valorAcumulado + nuevoElemento
) / arr.length;

const mitadLista1 = NUMBERS.length / 2;

function isEven(n) {
if (!n % 2 === 0) {
return true;
}
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());
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit afe4d17

Please sign in to comment.