Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…algorithms
  • Loading branch information
iAlgebra committed Nov 19, 2019
1 parent fb8dde0 commit 94803b0
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tareas/clase-4/algoritmo-10.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Desafío de programación #10: Calcula la suma de todos los números en un array de números
*/

function addArray(arr) {
let result = 0;
for (let i = 0; i < arr.length; i++) {
result += arr[i];
}
console.log(result);
}

addArray([100, 22, 43, 64, 15, 86, 70, 78, 19, 34]);
14 changes: 14 additions & 0 deletions tareas/clase-4/algoritmo-6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
Desafío de programación #6: Calcula 10! (10 factorial)
10 * 9 * 8 * ... * 1
*/

function calculatesTenFactorial(num = 10) {
let result = 1;
for (let i = 2; i <= num; i++) {
result *= i;
}
console.log(result);
}

calculatesTenFactorial(); // Also works for any other number
13 changes: 13 additions & 0 deletions tareas/clase-4/algoritmo-7.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Desafío de programación #7: Calcula la suma de todos los números impares mayores que 10 y menores que 30
*/

function addOddNumbersBetweenTenAndThirty() {
let result = 0;
for (let i = 11; i < 30; i += 2) {
result += i;
}
console.log(result);
}

addOddNumbersBetweenTenAndThirty();
13 changes: 13 additions & 0 deletions tareas/clase-4/algoritmo-8.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Desafío de programación #8: Crea una función que convierta de Celsius a Fahrenheit
*/

function fromCelsiusToFahrenheit(celsius) {
let fahrenheit;
const numberA = 9 / 5;
const numberB = 32;
fahrenheit = Number((celsius * numberA + numberB).toFixed(1));
console.log(celsius + '°C equals to ' + fahrenheit + '°F');
}

fromCelsiusToFahrenheit(36);
13 changes: 13 additions & 0 deletions tareas/clase-4/algoritmo-9.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Desafío de programación #9: Crea una función que convierta de Fahrenheit a Celsius
*/

function fromFahrenheitToCelsius(fahrenheit) {
let celsius;
const numberA = 32;
const numberB = 5 / 9;
celsius = Number(((fahrenheit - numberA) * numberB).toFixed(1));
console.log(fahrenheit + '°F equals to ' + celsius + '°C');
}

fromFahrenheitToCelsius(32);

0 comments on commit 94803b0

Please sign in to comment.