diff --git a/index.html b/index.html index 12a902b..0df4a7f 100644 --- a/index.html +++ b/index.html @@ -16,7 +16,7 @@

Ejercicios

- + diff --git a/main/main.js b/main/main.js new file mode 100644 index 0000000..0d21608 --- /dev/null +++ b/main/main.js @@ -0,0 +1,23 @@ +// ## Ejercicio #1 +// Escribir una función que tome un arreglo de números y devuelva el número mayor de la lista. +// Ejemplo del arreglo : [3, 5, 7, 1, 6] + +let lista = [3, 5, 7, 1, 6]; +console.log(Math.max(3, 5, 7, 1, 6)); +console.log(Math.max(...lista)); + + +function MyMax(nums) { + var n = nums.length; + maximo = nums[n-1]; + while (n--){ + if(nums[n] > maximo) { + maximo = nums[n] + } + } + return maximo; +}; + +var nums = [3, 5, 7, 1, 6]; +var m = MyMax(nums); +console.log(m) \ No newline at end of file