# Operación Mate JS

```function squareSum(numbers) {
return numbers.reduce((sum, n) => n * n + sum, 0);
}```
```// Opción 1:
function simpleMultiplication(n) {
return n * (n % 2 ? 9 : 8);
}

// Opción 2:
function simpleMultiplication(n){
return (n % 2 == 0) ? n * 8 : n * 9;
}

// Opción 3:
function simpleMultiplication(n){

if(n % 2 === 0 ){ //si el numero es par...
return n * 8;
}
else{ // si no lo es...
return n * 9;
}
}```
```//OPCIÓN 1
function getGrade (s1, s2, s3) {
avg = (s1+s2+s3)/3;
if (avg < 60)  return "F";
else if (avg < 70) return "D";
else if (avg < 80) return "C";
else if (avg < 90) return "B";
else return "A";
}

//OPCIÓN 2
let avg = scores.reduce((a, b) => a + b, 0) / scores.length;

if (avg < 60)  return "F";
else if (avg < 70) return "D";
else if (avg < 80) return "C";
else if (avg < 90) return "B";
else return "A";```
```const min = (list) => Math.min(...list);
const max = (list) => Math.max(...list);```
```function positiveSum(arr) {
var total = 0;
for (i = 0; i < arr.length; i++) {
if (arr[i] > 0) {                   // if arr[i] es mayor a 0
total += arr[i];                  // dar el total de la suma de esos arr[i]
}
}
}
```
```const points=games=>games.reduce((output,current)=>{
return output += current[0]>current[2] ? 3 : current[0]===current[2] ? 1 : 0;
},0)

//DIFERENTE ESCRITO:
function points(games) {
return games.reduce((output,current)=>{
let x = parseInt(current[0]);
let y = parseInt(current[2]);
let value= x>y ? 3 : x===y ? 1 : 0;
return output+value;
},0)
}```
```//Opción 1:
function findAverage(array) {
if(array.length === 0) {
return(0);
}
return array.reduce((a, b) => a + b, 0) / array.length;
}

//Opción 2:
var find_average = (array) => {
return array.length === 0 ? 0 : array.reduce((a, b)=> a + b, 0)/array.length
}
```
```function betterThanAverage(classPoints, yourPoints) {
return yourPoints > classPoints.reduce((a, b) => a + b, 0) / classPoints.length;
}
```