From 058751ccf0808693e5bfa84c74bee07c95e54999 Mon Sep 17 00:00:00 2001 From: Gomez1028 Date: Sat, 17 Aug 2024 11:46:40 -0500 Subject: [PATCH 1/9] C5 --- C5 Fundamentos Javascript/ejercicios/01.js | 2 +- C5 Fundamentos Javascript/ejercicios/02.js | 2 +- C5 Fundamentos Javascript/ejercicios/03.js | 2 +- C5 Fundamentos Javascript/ejercicios/04.js | 2 +- C5 Fundamentos Javascript/ejercicios/05.js | 2 +- C5 Fundamentos Javascript/ejercicios/06.js | 2 +- C5 Fundamentos Javascript/ejercicios/07.js | 1 + C5 Fundamentos Javascript/ejercicios/08.js | 8 +++++- C5 Fundamentos Javascript/ejercicios/09.js | 5 ++++ C5 Fundamentos Javascript/ejercicios/10.js | 1 + C5 Fundamentos Javascript/ejercicios/11.js | 7 +++-- C5 Fundamentos Javascript/ejercicios/12.js | 11 +++++++- C5 Fundamentos Javascript/ejercicios/13.js | 3 +- C5 Fundamentos Javascript/ejercicios/14.js | 1 + C5 Fundamentos Javascript/ejercicios/15.js | 5 ++++ C5 Fundamentos Javascript/ejercicios/16.js | 5 ++++ C5 Fundamentos Javascript/ejercicios/17.js | 14 +++++++++- C5 Fundamentos Javascript/ejercicios/18.js | 10 +++++++ C5 Fundamentos Javascript/ejercicios/19.js | 3 +- C5 Fundamentos Javascript/ejercicios/20.js | 1 + C5 Fundamentos Javascript/ejercicios/21.js | 1 + C5 Fundamentos Javascript/ejercicios/22.js | 1 + C5 Fundamentos Javascript/ejercicios/23.js | 3 +- C5 Fundamentos Javascript/ejercicios/24.js | 2 ++ C5 Fundamentos Javascript/ejercicios/25.js | 3 ++ C5 Fundamentos Javascript/ejercicios/26.js | 4 ++- C5 Fundamentos Javascript/ejercicios/27.js | 5 ++++ C5 Fundamentos Javascript/ejercicios/28.js | 2 ++ C5 Fundamentos Javascript/ejercicios/29.js | 1 + C5 Fundamentos Javascript/ejercicios/30.js | 4 +++ C5 Fundamentos Javascript/ejercicios/31.js | 4 +++ C5 Fundamentos Javascript/ejercicios/32.js | 2 ++ C5 Fundamentos Javascript/ejercicios/33.js | 1 + C5 Fundamentos Javascript/ejercicios/34.js | 2 ++ C5 Fundamentos Javascript/ejercicios/35.js | 1 + C5 Fundamentos Javascript/ejercicios/36.js | 1 + package-lock.json | 32 ++++++++++++---------- 37 files changed, 127 insertions(+), 29 deletions(-) diff --git a/C5 Fundamentos Javascript/ejercicios/01.js b/C5 Fundamentos Javascript/ejercicios/01.js index 62feaaf6f6..b889d03d8f 100644 --- a/C5 Fundamentos Javascript/ejercicios/01.js +++ b/C5 Fundamentos Javascript/ejercicios/01.js @@ -1,6 +1,6 @@ // Crea una variable de tipo string. // Reemplaza el valor de null por el correspondiente. -const nuevoString = null; +const nuevoString = 'null'; module.exports = nuevoString; \ No newline at end of file diff --git a/C5 Fundamentos Javascript/ejercicios/02.js b/C5 Fundamentos Javascript/ejercicios/02.js index d4f06a1b48..06674dc8fc 100644 --- a/C5 Fundamentos Javascript/ejercicios/02.js +++ b/C5 Fundamentos Javascript/ejercicios/02.js @@ -1,6 +1,6 @@ // Crea una variable de tipo number. // Reemplaza el valor de null por el correspondiente. -const nuevoNumero = null; +const nuevoNumero = 5; module.exports = nuevoNumero; \ No newline at end of file diff --git a/C5 Fundamentos Javascript/ejercicios/03.js b/C5 Fundamentos Javascript/ejercicios/03.js index 189ca4b52d..f2f01ede6f 100644 --- a/C5 Fundamentos Javascript/ejercicios/03.js +++ b/C5 Fundamentos Javascript/ejercicios/03.js @@ -1,6 +1,6 @@ // Crea una variable de tipo boolean. // Reemplaza el valor de null por el correspondiente. -const nuevoBoolean = null; +const nuevoBoolean = true; module.exports = nuevoBoolean; \ No newline at end of file diff --git a/C5 Fundamentos Javascript/ejercicios/04.js b/C5 Fundamentos Javascript/ejercicios/04.js index fff0fb6335..a52adb07c2 100644 --- a/C5 Fundamentos Javascript/ejercicios/04.js +++ b/C5 Fundamentos Javascript/ejercicios/04.js @@ -1,6 +1,6 @@ // Resuelve el siguiente problema matemático. // Reemplaza el valor de null por el correspondiente. -const nuevaResta = 10 - null === 3; +const nuevaResta = 10 - 7 === 3; module.exports = nuevaResta; \ No newline at end of file diff --git a/C5 Fundamentos Javascript/ejercicios/05.js b/C5 Fundamentos Javascript/ejercicios/05.js index 82e2dac5fe..0dabb9307d 100644 --- a/C5 Fundamentos Javascript/ejercicios/05.js +++ b/C5 Fundamentos Javascript/ejercicios/05.js @@ -1,6 +1,6 @@ // Resuelve el siguiente problema matemático. // Reemplaza el valor de null por el correspondiente. -const nuevaMultiplicacion = 10 * null === 40; +const nuevaMultiplicacion = 10 * 4 === 40; module.exports = nuevaMultiplicacion; \ No newline at end of file diff --git a/C5 Fundamentos Javascript/ejercicios/06.js b/C5 Fundamentos Javascript/ejercicios/06.js index 6debf25fc4..4fa4e9c7de 100644 --- a/C5 Fundamentos Javascript/ejercicios/06.js +++ b/C5 Fundamentos Javascript/ejercicios/06.js @@ -1,6 +1,6 @@ // Resuelve el siguiente problema matemático. // Reemplaza el valor de null por el correspondiente. -const nuevoModulo = 21 % 5 === null; +const nuevoModulo = 21 % 5 === 1; module.exports = nuevoModulo; diff --git a/C5 Fundamentos Javascript/ejercicios/07.js b/C5 Fundamentos Javascript/ejercicios/07.js index 8eecae1d84..9e0a779057 100644 --- a/C5 Fundamentos Javascript/ejercicios/07.js +++ b/C5 Fundamentos Javascript/ejercicios/07.js @@ -3,6 +3,7 @@ function esTipoDato(valor) { // Retorna el tipo de dato de este valor. // Por ejemplo: "string", "number", "boolean", "object", etc. // Tu código: + return typeof valor; } module.exports = esTipoDato; \ No newline at end of file diff --git a/C5 Fundamentos Javascript/ejercicios/08.js b/C5 Fundamentos Javascript/ejercicios/08.js index b6594f3466..2c6c448620 100644 --- a/C5 Fundamentos Javascript/ejercicios/08.js +++ b/C5 Fundamentos Javascript/ejercicios/08.js @@ -7,6 +7,12 @@ function esNumeroEntero(numero) { // -1212 ---> true // 121.212 ---> false // Tu código: + if (Number.isInteger(numero)) { + return true + } else { + return false + } } -module.exports = esNumeroEntero; \ No newline at end of file +module.exports = esNumeroEntero; + diff --git a/C5 Fundamentos Javascript/ejercicios/09.js b/C5 Fundamentos Javascript/ejercicios/09.js index 665d437709..6fe2b8a073 100644 --- a/C5 Fundamentos Javascript/ejercicios/09.js +++ b/C5 Fundamentos Javascript/ejercicios/09.js @@ -8,6 +8,11 @@ function esNuloOIndefinido(valor) { // 22 ---> false // "texto" ---> false // Tu código: + if (valor === null || valor === undefined) { + return true + } else { + return false + } } module.exports = esNuloOIndefinido; \ No newline at end of file diff --git a/C5 Fundamentos Javascript/ejercicios/10.js b/C5 Fundamentos Javascript/ejercicios/10.js index a2f730da93..b9ea975f69 100644 --- a/C5 Fundamentos Javascript/ejercicios/10.js +++ b/C5 Fundamentos Javascript/ejercicios/10.js @@ -6,6 +6,7 @@ function devolverString(string) { // "hola mundo" ---> "hola mundo" // "SoyHenry" ---> "SoyHenry" // Tu código: + return string; } module.exports = devolverString; \ No newline at end of file diff --git a/C5 Fundamentos Javascript/ejercicios/11.js b/C5 Fundamentos Javascript/ejercicios/11.js index 2a4d40a899..f12c53180f 100644 --- a/C5 Fundamentos Javascript/ejercicios/11.js +++ b/C5 Fundamentos Javascript/ejercicios/11.js @@ -6,6 +6,9 @@ function sonIguales(x, y) { // 5, 5 ---> true // 5, 8 ---> false // Tu código: -} + if (x === y){ + return true + } return false +} -module.exports = sonIguales; \ No newline at end of file +module.exports = sonIguales; diff --git a/C5 Fundamentos Javascript/ejercicios/12.js b/C5 Fundamentos Javascript/ejercicios/12.js index bce832204b..4753c5ee57 100644 --- a/C5 Fundamentos Javascript/ejercicios/12.js +++ b/C5 Fundamentos Javascript/ejercicios/12.js @@ -6,6 +6,15 @@ function tienenMismaLongitud(str1, str2) { // "SoyHenry", "HenrySoy" ---> true // "hi", "there" ---> false // Tu código: + // cualquier opcion esta bien + //if(str1.length === str2.length){ + //return true + //} else { + //return false + //} + + return str1.length === str2.length } -module.exports = tienenMismaLongitud; \ No newline at end of file + +module.exports = tienenMismaLongitud; diff --git a/C5 Fundamentos Javascript/ejercicios/13.js b/C5 Fundamentos Javascript/ejercicios/13.js index 5e4d000dd4..925d1d3f1d 100644 --- a/C5 Fundamentos Javascript/ejercicios/13.js +++ b/C5 Fundamentos Javascript/ejercicios/13.js @@ -6,6 +6,7 @@ function menosQueNoventa(num) { // 50 ---> true // 91 ---> false // Tu código: + return num <90; } -module.exports = menosQueNoventa; \ No newline at end of file +module.exports = menosQueNoventa; diff --git a/C5 Fundamentos Javascript/ejercicios/14.js b/C5 Fundamentos Javascript/ejercicios/14.js index cd5d24fbd1..01160cb8ad 100644 --- a/C5 Fundamentos Javascript/ejercicios/14.js +++ b/C5 Fundamentos Javascript/ejercicios/14.js @@ -6,6 +6,7 @@ function mayorQueCincuenta(num) { // 51 ---> true // 15 ---> false // Tu código: + return num > 50; } module.exports = mayorQueCincuenta; diff --git a/C5 Fundamentos Javascript/ejercicios/15.js b/C5 Fundamentos Javascript/ejercicios/15.js index 98648a7167..94067e861d 100644 --- a/C5 Fundamentos Javascript/ejercicios/15.js +++ b/C5 Fundamentos Javascript/ejercicios/15.js @@ -6,6 +6,11 @@ function esPar(num) { // 14 ---> true // 15 ---> false // Tu código: + if (num % 2 === 0) { + return true + } else { + return false + } } module.exports = esPar; diff --git a/C5 Fundamentos Javascript/ejercicios/16.js b/C5 Fundamentos Javascript/ejercicios/16.js index 7721e84f50..65e4ad82df 100644 --- a/C5 Fundamentos Javascript/ejercicios/16.js +++ b/C5 Fundamentos Javascript/ejercicios/16.js @@ -6,6 +6,11 @@ function esImpar(num) { // 15 ---> true // 14 ---> false // Tu código: + if (num % 2 !== 0) { + return true + } else { + return false + } } module.exports = esImpar; \ No newline at end of file diff --git a/C5 Fundamentos Javascript/ejercicios/17.js b/C5 Fundamentos Javascript/ejercicios/17.js index dc0f6d6a95..2430b30ced 100644 --- a/C5 Fundamentos Javascript/ejercicios/17.js +++ b/C5 Fundamentos Javascript/ejercicios/17.js @@ -6,6 +6,18 @@ function esPositivo(num) { // Si el número es negativo ---> "Es negativo". // Si el número es 0, devuelve false. // Tu código: + if (num > 0) { + return ('Es positivo') + } else if (num === 0){ + return false + }// else if (num % 1 !== 0){ + //return ('Es decimal') + //} + else { + return ('Es negativo') + } } -module.exports = esPositivo; \ No newline at end of file +module.exports = esPositivo; + +console.log(esPositivo(-1.5)) \ No newline at end of file diff --git a/C5 Fundamentos Javascript/ejercicios/18.js b/C5 Fundamentos Javascript/ejercicios/18.js index 180f3bff3d..680eaa8489 100644 --- a/C5 Fundamentos Javascript/ejercicios/18.js +++ b/C5 Fundamentos Javascript/ejercicios/18.js @@ -8,6 +8,16 @@ function esVocal(letra) { // "n" ---> "Dato incorrecto" // "texto largo" ---> "Dato incorrecto" // Tu código: + if (letra.length != 1){ + return ('Dato incorrecto') + } + + if(letra === 'a' || letra === 'e' || letra ==='i' || letra === 'o' || letra === 'u') { + return ('Es vocal') + } else { + return ('Dato incorrecto') + } } module.exports = esVocal; + diff --git a/C5 Fundamentos Javascript/ejercicios/19.js b/C5 Fundamentos Javascript/ejercicios/19.js index eadd4aa24e..f7a8bd7a76 100644 --- a/C5 Fundamentos Javascript/ejercicios/19.js +++ b/C5 Fundamentos Javascript/ejercicios/19.js @@ -5,6 +5,7 @@ function suma(x, y) { // 5, 5 ---> 10 // -5, 5 ---> 0 // Tu código: + return x + y; } -module.exports = suma; \ No newline at end of file +module.exports = suma; diff --git a/C5 Fundamentos Javascript/ejercicios/20.js b/C5 Fundamentos Javascript/ejercicios/20.js index 85e2de4890..8a3a3abb41 100644 --- a/C5 Fundamentos Javascript/ejercicios/20.js +++ b/C5 Fundamentos Javascript/ejercicios/20.js @@ -5,6 +5,7 @@ function resta(x, y) { // 10, 5 ---> 5 // 5, 5 ---> 0 // Tu código: + return x - y; } module.exports = resta; \ No newline at end of file diff --git a/C5 Fundamentos Javascript/ejercicios/21.js b/C5 Fundamentos Javascript/ejercicios/21.js index 747fe977f9..91af9a3c5a 100644 --- a/C5 Fundamentos Javascript/ejercicios/21.js +++ b/C5 Fundamentos Javascript/ejercicios/21.js @@ -5,6 +5,7 @@ function multiplica(x, y) { // 10, 5 ---> 50 // 5, 5 ---> 25 // Tu código: + return x * y; } module.exports = multiplica; \ No newline at end of file diff --git a/C5 Fundamentos Javascript/ejercicios/22.js b/C5 Fundamentos Javascript/ejercicios/22.js index 57e0e9c6e7..a366cead9c 100644 --- a/C5 Fundamentos Javascript/ejercicios/22.js +++ b/C5 Fundamentos Javascript/ejercicios/22.js @@ -5,6 +5,7 @@ function divide(x, y) { // 10, 5 ---> 2 // 5, 5 ---> 1 // Tu código: + return x / y; } module.exports = divide; \ No newline at end of file diff --git a/C5 Fundamentos Javascript/ejercicios/23.js b/C5 Fundamentos Javascript/ejercicios/23.js index 05b43b2135..a67c5eddbb 100644 --- a/C5 Fundamentos Javascript/ejercicios/23.js +++ b/C5 Fundamentos Javascript/ejercicios/23.js @@ -5,6 +5,7 @@ function obtenerResto(x, y) { // 10, 5 ---> 0 // 16, 5 ---> 1 // Tu código: + return x % y; } -module.exports = obtenerResto; \ No newline at end of file +module.exports = obtenerResto; diff --git a/C5 Fundamentos Javascript/ejercicios/24.js b/C5 Fundamentos Javascript/ejercicios/24.js index 0c25f1a616..c4ffdec9e4 100644 --- a/C5 Fundamentos Javascript/ejercicios/24.js +++ b/C5 Fundamentos Javascript/ejercicios/24.js @@ -4,6 +4,8 @@ function agregarSimboloExclamacion(str) { // Por ejemplo: // "hello world" ---> "hello world!" // Tu código: + return (str + ('!')); } module.exports = agregarSimboloExclamacion; + diff --git a/C5 Fundamentos Javascript/ejercicios/25.js b/C5 Fundamentos Javascript/ejercicios/25.js index 6e2e9ed067..d1c6307c5a 100644 --- a/C5 Fundamentos Javascript/ejercicios/25.js +++ b/C5 Fundamentos Javascript/ejercicios/25.js @@ -4,6 +4,9 @@ function combinarNombres(nombre, apellido) { // Por ejemplo: // "Soy", "Henry" ---> "Soy Henry" // Tu código: + return (nombre + ' ' + apellido) } module.exports = combinarNombres; + +console.log(combinarNombres('fabio', 'gomez')) \ No newline at end of file diff --git a/C5 Fundamentos Javascript/ejercicios/26.js b/C5 Fundamentos Javascript/ejercicios/26.js index 2a0f6ceafc..68efb30c79 100644 --- a/C5 Fundamentos Javascript/ejercicios/26.js +++ b/C5 Fundamentos Javascript/ejercicios/26.js @@ -4,6 +4,8 @@ function obtenerSaludo(nombre) { // Ejemplo: "Martin" ---> "Hola Martin!" // Retorna el nuevo string. // Tu código: + return ('Hola' + ' ' + nombre + '!'); } -module.exports = obtenerSaludo; \ No newline at end of file +module.exports = obtenerSaludo; + diff --git a/C5 Fundamentos Javascript/ejercicios/27.js b/C5 Fundamentos Javascript/ejercicios/27.js index e786d71a11..f0887c42b4 100644 --- a/C5 Fundamentos Javascript/ejercicios/27.js +++ b/C5 Fundamentos Javascript/ejercicios/27.js @@ -5,6 +5,11 @@ function obtenerAreaRectangulo(alto, ancho) { // 2, 2 ---> 4 // 0, 2 ---> 2 // Tu código: + + return alto * ancho; + } module.exports = obtenerAreaRectangulo; + + diff --git a/C5 Fundamentos Javascript/ejercicios/28.js b/C5 Fundamentos Javascript/ejercicios/28.js index c86f27e883..2833d5b943 100644 --- a/C5 Fundamentos Javascript/ejercicios/28.js +++ b/C5 Fundamentos Javascript/ejercicios/28.js @@ -5,6 +5,8 @@ function retornarPerimetro(lado) { // 2 ---> 8 // 0 ---> 0 // Tu código: + return lado * 4 } module.exports = retornarPerimetro; + diff --git a/C5 Fundamentos Javascript/ejercicios/29.js b/C5 Fundamentos Javascript/ejercicios/29.js index 8e7d52ff15..591edb8fd2 100644 --- a/C5 Fundamentos Javascript/ejercicios/29.js +++ b/C5 Fundamentos Javascript/ejercicios/29.js @@ -5,6 +5,7 @@ function areaDelTriangulo(base, altura) { // 10, 5 ---> 25 // 0, 10 ---> 0 // Tu código: + return (base * altura) / 2; } module.exports = areaDelTriangulo; diff --git a/C5 Fundamentos Javascript/ejercicios/30.js b/C5 Fundamentos Javascript/ejercicios/30.js index 6f0882f77d..ec32944a79 100644 --- a/C5 Fundamentos Javascript/ejercicios/30.js +++ b/C5 Fundamentos Javascript/ejercicios/30.js @@ -7,6 +7,10 @@ function deEuroAdolar(euro) { // 1 ---> 1.20 // 0 ---> 0 // Tu código: + const EuroADolar = 1.20; + return euro * EuroADolar; + } module.exports = deEuroAdolar; + diff --git a/C5 Fundamentos Javascript/ejercicios/31.js b/C5 Fundamentos Javascript/ejercicios/31.js index 823f0fb17b..81cd7e57d3 100644 --- a/C5 Fundamentos Javascript/ejercicios/31.js +++ b/C5 Fundamentos Javascript/ejercicios/31.js @@ -7,6 +7,10 @@ function elevarAlCuadrado(num) { // 6 ---> 36 // 0 ---> 0 // Tu código: + //return num ** 2 + return Math.pow(num, 2) } module.exports = elevarAlCuadrado; + +console.log(elevarAlCuadrado(2)) diff --git a/C5 Fundamentos Javascript/ejercicios/32.js b/C5 Fundamentos Javascript/ejercicios/32.js index 7150676698..6d2994ce44 100644 --- a/C5 Fundamentos Javascript/ejercicios/32.js +++ b/C5 Fundamentos Javascript/ejercicios/32.js @@ -7,6 +7,8 @@ function elevarAlCubo(num) { // 3 ---> 27 // 0 ---> 0 // Tu código: + return Math.pow(num, 3) + } module.exports = elevarAlCubo; diff --git a/C5 Fundamentos Javascript/ejercicios/33.js b/C5 Fundamentos Javascript/ejercicios/33.js index 09944ed939..83a16c3411 100644 --- a/C5 Fundamentos Javascript/ejercicios/33.js +++ b/C5 Fundamentos Javascript/ejercicios/33.js @@ -7,6 +7,7 @@ function elevar(num, exponent) { // 2, 2 ---> 4 // 0, 5 ---> 0 // Tu código: + return Math.pow(num, exponent) } module.exports = elevar; \ No newline at end of file diff --git a/C5 Fundamentos Javascript/ejercicios/34.js b/C5 Fundamentos Javascript/ejercicios/34.js index 2fff9db0e4..2a433f0e90 100644 --- a/C5 Fundamentos Javascript/ejercicios/34.js +++ b/C5 Fundamentos Javascript/ejercicios/34.js @@ -7,6 +7,8 @@ function redondearNumero(num) { // 1.5 ---> 2 // 0.1 ---> 0 // Tu código: + return Math.round(num) } module.exports = redondearNumero; + diff --git a/C5 Fundamentos Javascript/ejercicios/35.js b/C5 Fundamentos Javascript/ejercicios/35.js index 1987c119d4..34b2b888da 100644 --- a/C5 Fundamentos Javascript/ejercicios/35.js +++ b/C5 Fundamentos Javascript/ejercicios/35.js @@ -7,6 +7,7 @@ function redondearHaciaArriba(num) { // 2.5 ---> 3 // 0.1 ---> 1 // Tu código: + return Math.ceil(num) } module.exports = redondearHaciaArriba; \ No newline at end of file diff --git a/C5 Fundamentos Javascript/ejercicios/36.js b/C5 Fundamentos Javascript/ejercicios/36.js index d0288d803f..7246defa43 100644 --- a/C5 Fundamentos Javascript/ejercicios/36.js +++ b/C5 Fundamentos Javascript/ejercicios/36.js @@ -3,6 +3,7 @@ function numeroRandom() { // La función numeroRandom debe generar un número al azar entre 0 y 1 y retornarlo. // Tu código: + return Math.random() } module.exports = numeroRandom; diff --git a/package-lock.json b/package-lock.json index bbf7bb73b8..9eabdfec8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1211,11 +1211,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "license": "MIT", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -1597,9 +1598,10 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "license": "MIT", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -1820,6 +1822,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "license": "MIT", "engines": { "node": ">=0.12.0" } @@ -3149,6 +3152,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "license": "MIT", "dependencies": { "is-number": "^7.0.0" }, @@ -4257,11 +4261,11 @@ } }, "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "requires": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" } }, "browserslist": { @@ -4508,9 +4512,9 @@ } }, "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "requires": { "to-regex-range": "^5.0.1" } From 0a46edb9f410be167500c44e6789732af462fadc Mon Sep 17 00:00:00 2001 From: Gomez1028 Date: Sat, 17 Aug 2024 13:59:52 -0500 Subject: [PATCH 2/9] hola --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7845492974..653aab02d4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![HenryLogo](./assets/logoBannerHenry.png) +gi![HenryLogo](./assets/logoBannerHenry.png) # **🧑‍💻 PREP COURSE | HENRY 👩‍💻** @@ -7,6 +7,7 @@ ¡Hola 😄! Bienvenid@ al Prep Course para la carrera de Desarrollo Web Full Stack. En este curso introductorio podrás aprender y practicar todo el contenido que necesitas para convertirte en un desarrollador de JavaScript. Encontrarás todo el material que necesitas para lograr avanzar en la evaluación del Henry Challenge (último paso para ingresar a la carrera de Desarrollo Web Full Stack). +hola soy fabio
From f6752e065dff79652ec834b6f09871304fd8a714 Mon Sep 17 00:00:00 2001 From: Gomez1028 Date: Sat, 17 Aug 2024 20:31:47 -0500 Subject: [PATCH 3/9] C6 --- C6 Bucles/ejercicios/01.js | 6 ++++++ C6 Bucles/ejercicios/02.js | 6 ++++++ C6 Bucles/ejercicios/03.js | 8 ++++++++ C6 Bucles/ejercicios/04.js | 6 ++++++ C6 Bucles/ejercicios/05.js | 5 +++++ C6 Bucles/ejercicios/06.js | 8 ++++++++ C6 Bucles/ejercicios/07.js | 5 +++++ C6 Bucles/ejercicios/08.js | 5 +++++ C6 Bucles/ejercicios/09.js | 9 +++++++++ C6 Bucles/ejercicios/10.js | 5 +++++ C6 Bucles/ejercicios/11.js | 5 +++++ C6 Bucles/ejercicios/12.js | 11 +++++++++++ C6 Bucles/ejercicios/13.js | 6 ++++++ C6 Bucles/ejercicios/14.js | 14 ++++++++++++++ C6 Bucles/ejercicios/15.js | 22 +++++++++++++++++++++- C6 Bucles/ejercicios/16.js | 14 ++++++++++++++ C6 Bucles/ejercicios/17.js | 14 ++++++++++++++ C6 Bucles/ejercicios/18.js | 10 +++++++++- C6 Bucles/ejercicios/19.js | 10 ++++++++++ C6 Bucles/ejercicios/20.js | 12 ++++++++++++ C6 Bucles/ejercicios/21.js | 14 ++++++++++++++ C6 Bucles/ejercicios/22.js | 12 +++++++++++- C6 Bucles/ejercicios/23.js | 15 +++++++++++++++ 23 files changed, 219 insertions(+), 3 deletions(-) diff --git a/C6 Bucles/ejercicios/01.js b/C6 Bucles/ejercicios/01.js index 95f2825332..bd6dc6c635 100644 --- a/C6 Bucles/ejercicios/01.js +++ b/C6 Bucles/ejercicios/01.js @@ -3,6 +3,12 @@ function esIgualYNegativo(a, b) { // Determina si son iguales y son ambos negativos. // De ser así, retorna true, de lo contrario, retorna false. // Tu código: + if(a === b && (a < 0) && (b < 0)) { + return true + } else { + return false + } } module.exports = esIgualYNegativo; + diff --git a/C6 Bucles/ejercicios/02.js b/C6 Bucles/ejercicios/02.js index a98deee96a..438344d76a 100644 --- a/C6 Bucles/ejercicios/02.js +++ b/C6 Bucles/ejercicios/02.js @@ -2,6 +2,12 @@ function esVerdaderoYFalso(booleano1, booleano2) { // La función recibe dos argumentos "booleano1" y "booleano2". // Retorna true si ambos son verdaderos, caso contrario, retorna false. // Tu código: + if(booleano1 === true && booleano2 === true){ + return true + } else { + return false + } } module.exports = esVerdaderoYFalso; + diff --git a/C6 Bucles/ejercicios/03.js b/C6 Bucles/ejercicios/03.js index 95d1b1f4c3..e5e46e32fc 100644 --- a/C6 Bucles/ejercicios/03.js +++ b/C6 Bucles/ejercicios/03.js @@ -3,6 +3,14 @@ function obtenerMayor(x, y) { // Retorna el número más grande. // Si son iguales, retornar cualquiera de los dos. // Tu código: + if(x > y){ + return x + } else if (y > x){ + return y + } else if (x === y) { + return (x || y) + } } module.exports = obtenerMayor; + diff --git a/C6 Bucles/ejercicios/04.js b/C6 Bucles/ejercicios/04.js index 7ef7a58d03..f286e8e0b3 100644 --- a/C6 Bucles/ejercicios/04.js +++ b/C6 Bucles/ejercicios/04.js @@ -3,6 +3,12 @@ function mayoriaDeEdad(edad) { // Si tiene 18 años o más, retorna el string: "Allowed". // Caso contrario: "Not allowed". // Tu código: + if(edad >= 18){ + return ('Allowed') + } else { + return ('Not allowed') + } } module.exports = mayoriaDeEdad; + diff --git a/C6 Bucles/ejercicios/05.js b/C6 Bucles/ejercicios/05.js index ee7e89c431..a4d9b03249 100644 --- a/C6 Bucles/ejercicios/05.js +++ b/C6 Bucles/ejercicios/05.js @@ -2,6 +2,11 @@ function esVerdadero(valor) { // Si "valor" es verdadero, retorna "Soy verdadero". // Caso contrario, retorna "Soy falso". // Tu código: + if(valor === true) { + return ('Soy verdadero') + } else { + return ('Soy falso') + } } module.exports = esVerdadero; diff --git a/C6 Bucles/ejercicios/06.js b/C6 Bucles/ejercicios/06.js index b7c047365b..8dc482b42e 100644 --- a/C6 Bucles/ejercicios/06.js +++ b/C6 Bucles/ejercicios/06.js @@ -2,6 +2,14 @@ function tieneTresDigitos(num) { // Si el número recibido tiene tres dígitos, retorna true. // Caso contrario, retorna false. // Tu código: + + if (Math.abs(num) > 100 && Math.abs(num) < 1000 ) { + return true + } else { + return false + } } module.exports = tieneTresDigitos; + +console.log(tieneTresDigitos(-12)) diff --git a/C6 Bucles/ejercicios/07.js b/C6 Bucles/ejercicios/07.js index 5191b315af..be60e56064 100644 --- a/C6 Bucles/ejercicios/07.js +++ b/C6 Bucles/ejercicios/07.js @@ -3,6 +3,11 @@ function esParYDivisiblePorTres(a) { // Retorna true si este es par y divisible por tres a la vez. // Retorna false si no lo es. // Tu código: + if(a % 2 === 0 && a % 3 === 0){ + return true + } else { + return false + } } module.exports = esParYDivisiblePorTres; \ No newline at end of file diff --git a/C6 Bucles/ejercicios/08.js b/C6 Bucles/ejercicios/08.js index bb5f11d4c0..6176bd36da 100644 --- a/C6 Bucles/ejercicios/08.js +++ b/C6 Bucles/ejercicios/08.js @@ -3,6 +3,11 @@ function esPositivoOInferiorA10(a) { // Retorna true si es positivo y menor que 10. // Retorna false en caso contrario. // Tu código: + if(a > 0 && a < 10){ + return true + } else { + return false + } } module.exports = esPositivoOInferiorA10; diff --git a/C6 Bucles/ejercicios/09.js b/C6 Bucles/ejercicios/09.js index f3898b19c7..acb8a70ea2 100644 --- a/C6 Bucles/ejercicios/09.js +++ b/C6 Bucles/ejercicios/09.js @@ -5,6 +5,15 @@ function conection(status) { // De lo contrario, presumimos que el usuario está "Offline". // Retornar el estado de conexión del usuario. // Tu código: + if(status === 1){ + return ('Online') + } else if (status === 2){ + return ('Away') + } else { + return ('Offline') + } } module.exports = conection; + +console.log(conection(3)) diff --git a/C6 Bucles/ejercicios/10.js b/C6 Bucles/ejercicios/10.js index 2620c50f93..0df273387e 100644 --- a/C6 Bucles/ejercicios/10.js +++ b/C6 Bucles/ejercicios/10.js @@ -2,6 +2,11 @@ function esDiezOCinco(num) { // Retornar true si "num" es 10 o 5. // De lo contrario, retornar false. // Tu código: + if (num === 10 || num === 5){ + return true + } else { + return false + } } module.exports = esDiezOCinco; diff --git a/C6 Bucles/ejercicios/11.js b/C6 Bucles/ejercicios/11.js index f35ed4ab3d..1b570f5045 100644 --- a/C6 Bucles/ejercicios/11.js +++ b/C6 Bucles/ejercicios/11.js @@ -2,6 +2,11 @@ function estaEnRango(num) { // Retorna true si "num" es menor que 50 y mayor que 20. // De lo contrario, retornar false. // Tu código: + if(num<50 && num>20){ + return true + } else { + return false + } } module.exports = estaEnRango; diff --git a/C6 Bucles/ejercicios/12.js b/C6 Bucles/ejercicios/12.js index b61a3aec43..4ac0e1e105 100644 --- a/C6 Bucles/ejercicios/12.js +++ b/C6 Bucles/ejercicios/12.js @@ -4,6 +4,17 @@ function fizzBuzz(num) { // Si "num" es divisible entre 3 y 5 (ambos), retorna "fizzbuzz". // De lo contrario, retorna false. // Tu código: + if(num % 3 === 0 && num % 5 === 0){ + return ('fizzbuzz') + } else if(num % 5 === 0){ + return ('buzz') + } else if(num % 3 === 0){ + return ('fizz') + }else { + return false + } } module.exports = fizzBuzz; + +console.log(fizzBuzz(9)) diff --git a/C6 Bucles/ejercicios/13.js b/C6 Bucles/ejercicios/13.js index 76e254264a..d2e3c8d071 100644 --- a/C6 Bucles/ejercicios/13.js +++ b/C6 Bucles/ejercicios/13.js @@ -5,6 +5,12 @@ function esEntero(num) { // Ejemplo: (-10) ---> true // De lo contrario, retorna false. // Tu código: + if(Number.isInteger(num)){ + return true + } else { + return false + } } module.exports = esEntero; + diff --git a/C6 Bucles/ejercicios/14.js b/C6 Bucles/ejercicios/14.js index 285d4fdfe2..17c86bad13 100644 --- a/C6 Bucles/ejercicios/14.js +++ b/C6 Bucles/ejercicios/14.js @@ -6,6 +6,20 @@ function operadoresLogicos(num1, num2, num3) { // Si todos los argumentos son cero, retorna ---> "Error". // Si no se cumple ninguna de las condiciones anteriores, retorna false. // Tu código: + if(num1 > num2 && num1 > num3 > 0) { + return ('Numero 1 es mayor y positivo') + } else if(num1<0 || num2<0 || num3<0){ + return ('Hay negativos') + }else if(num3 > num1 && num3 > num2){ + num3 += 1 + return num3 + }else if(num1===0 && num2===0 && num3===0){ + return ('Error') + } else { + return false + } } module.exports = operadoresLogicos; + +console.log(operadoresLogicos(0,20,0)) diff --git a/C6 Bucles/ejercicios/15.js b/C6 Bucles/ejercicios/15.js index 906f514225..728fd35b01 100644 --- a/C6 Bucles/ejercicios/15.js +++ b/C6 Bucles/ejercicios/15.js @@ -6,6 +6,26 @@ function obtenerDiaSemana(numero) { // Si el número no corresponde a un día de la semana, retorna // el string "No es un dia de la semana" // Tu código: + switch (numero){ + case 1: + return ('Lunes'); + case 2: + return ('Martes'); + case 3: + return ('Miercoles'); + case 4: + return ('Jueves'); + case 5: + return ('Viernes'); + case 6: + return ('Sabado'); + case 7: + return ('Domingo'); + break + default: + return ('No es un dia de la semana'); + } } -module.exports = obtenerDiaSemana; \ No newline at end of file +module.exports = obtenerDiaSemana; + diff --git a/C6 Bucles/ejercicios/16.js b/C6 Bucles/ejercicios/16.js index 01a50c9f01..21a5243553 100644 --- a/C6 Bucles/ejercicios/16.js +++ b/C6 Bucles/ejercicios/16.js @@ -5,6 +5,20 @@ function saludo(idioma) { // Si "idioma" es "ingles", devuelve "Hello!". // Si "idioma" no es ninguno de los anteriores o es `undefined`, devuelve "Hola!". // Tu código: + switch (idioma){ + case 'aleman': + return 'Guten Tag!'; + case 'mandarin': + return 'Ni Hao!' + case 'ingles': + return 'Hello!' + break + default: + return 'Hola!' + } + } module.exports = saludo; + +console.log(saludo('aleman')) diff --git a/C6 Bucles/ejercicios/17.js b/C6 Bucles/ejercicios/17.js index 3dcc148517..f690f74d36 100644 --- a/C6 Bucles/ejercicios/17.js +++ b/C6 Bucles/ejercicios/17.js @@ -7,6 +7,20 @@ function colors(color) { // Si no es ninguno de esos colores --> "Color not found". // PISTA: utilizar el statement SWITCH. // Tu código: + switch(color){ + case 'blue': + return 'This is blue'; + case 'red': + return 'This is red'; + case 'green': + return 'This is green'; + case 'orange': + return 'This is organge'; + break + default: + return 'Color not found'; + } } module.exports = colors; + diff --git a/C6 Bucles/ejercicios/18.js b/C6 Bucles/ejercicios/18.js index e7183ff019..e3f4705d14 100644 --- a/C6 Bucles/ejercicios/18.js +++ b/C6 Bucles/ejercicios/18.js @@ -2,6 +2,14 @@ function productoEntreNúmeros(a, b) { // Dados dos argumentos "a" y "b", devuelve el producto de todos // los números entre a y b (inclusive). // Tu código: + + var producto = 1; + + for(var i = a; i<=b; i++) + producto *= i + return producto } -module.exports = productoEntreNúmeros; \ No newline at end of file +module.exports = productoEntreNúmeros; + +console.log(productoEntreNúmeros(5,5)) diff --git a/C6 Bucles/ejercicios/19.js b/C6 Bucles/ejercicios/19.js index 41c47d54eb..b588f8c69a 100644 --- a/C6 Bucles/ejercicios/19.js +++ b/C6 Bucles/ejercicios/19.js @@ -2,6 +2,16 @@ function sumarHastaN(n) { // La función recibe un número "n" por argumento. // Devuelve la suma de todos los números desde 1 hasta n. // Tu código: + var suma = 0; + + for(var i = 1; i<=n; i++){ + suma += i; + } + + return suma; + } module.exports = sumarHastaN; + +console.log(sumarHastaN(5)) diff --git a/C6 Bucles/ejercicios/20.js b/C6 Bucles/ejercicios/20.js index 4c835a54d4..c0bc2fb316 100644 --- a/C6 Bucles/ejercicios/20.js +++ b/C6 Bucles/ejercicios/20.js @@ -3,6 +3,18 @@ function sumarHastaNConBreak(n) { // Devuelve la suma de todos los números desde 1 hasta n. // Si la suma supera a 100, detén el bucle usando break. // Tu código: + var suma = 0 + + for(var i = 1; i<= n; i++){ + suma += i; + if(suma >100){ + break + } + } + + return suma } module.exports = sumarHastaNConBreak; + +console.log(sumarHastaNConBreak(5)) diff --git a/C6 Bucles/ejercicios/21.js b/C6 Bucles/ejercicios/21.js index 1107bf2a11..4af76cdc62 100644 --- a/C6 Bucles/ejercicios/21.js +++ b/C6 Bucles/ejercicios/21.js @@ -4,6 +4,20 @@ function esPotenciaDeDos(numero) { // Devuelve true si lo es, sino devuelve false. // PISTA: Utiliza un bucle while. // Tu código: + if(numero <= 0){ + return false + } + + while (numero !== 1){ + if(numero % 2 !== 0){ + return false //por que si no es divisible por 0 no es potencia de 2 + } + + numero = numero /2 + } + + return true } module.exports = esPotenciaDeDos; + diff --git a/C6 Bucles/ejercicios/22.js b/C6 Bucles/ejercicios/22.js index 308536602f..b7aba578f5 100644 --- a/C6 Bucles/ejercicios/22.js +++ b/C6 Bucles/ejercicios/22.js @@ -3,6 +3,16 @@ function doWhile(num) { // Retorna el valor final. // PISTA: Utiliza el bucle do-while. // Tu código: + var i = 0 + + do { + num += 5 + i++ + }while (i<8); + + return num } -module.exports = doWhile; \ No newline at end of file +module.exports = doWhile; + +console.log(doWhile(100)) \ No newline at end of file diff --git a/C6 Bucles/ejercicios/23.js b/C6 Bucles/ejercicios/23.js index ebe222a114..d5bac3040e 100644 --- a/C6 Bucles/ejercicios/23.js +++ b/C6 Bucles/ejercicios/23.js @@ -6,6 +6,21 @@ function esNumeroPrimo(numero) { // IMPORTANTE: Recuerda que un número primo es aquel que // solo es divisible por sí mismo y por 1. // Tu código: + if(numero <= 1){ + return false + } + // Verificamos la divisibilidad desde 2 hasta la raíz cuadrada del número + for(var i = 2; i<=Math.sqrt(numero); i++){ + if(numero % i === 0){//verifamos que no hayan divisores + return false + } + } + return true } module.exports = esNumeroPrimo; + +console.log(esNumeroPrimo(2)) + +var num = (4 % 2) +console.log(num) \ No newline at end of file From b04f7ed8c4a3be07ac5b3625323f71fa51a1f601 Mon Sep 17 00:00:00 2001 From: Gomez1028 Date: Tue, 20 Aug 2024 12:20:02 -0500 Subject: [PATCH 4/9] C7 --- C5 Fundamentos Javascript/ejercicios/18.js | 6 +-- C7 Arrays/ejercicios/01.js | 2 + C7 Arrays/ejercicios/02.js | 5 +++ C7 Arrays/ejercicios/03.js | 2 + C7 Arrays/ejercicios/04.js | 4 ++ C7 Arrays/ejercicios/05.js | 5 ++- C7 Arrays/ejercicios/06.js | 16 ++++++++ C7 Arrays/ejercicios/07.js | 5 +++ C7 Arrays/ejercicios/08.js | 11 ++++++ C7 Arrays/ejercicios/09.js | 7 ++++ C7 Arrays/ejercicios/10.js | 4 ++ C7 Arrays/ejercicios/11.js | 5 +++ C7 Arrays/ejercicios/12.js | 10 +++++ C7 Arrays/ejercicios/13.js | 14 +++++++ C7 Arrays/ejercicios/14.js | 5 +++ C7 Arrays/ejercicios/15.js | 9 +++++ C7 Arrays/ejercicios/16.js | 5 +++ C7 Arrays/ejercicios/17.js | 5 +++ C7 Arrays/ejercicios/18.js | 9 +++++ C7 Arrays/ejercicios/19.js | 18 +++++++++ C7 Arrays/ejercicios/20.js | 14 +++++++ C7 Arrays/ejercicios/21.js | 32 +++++++++++++++ C7 Arrays/ejercicios/22.js | 12 ++++++ C7 Arrays/ejercicios/23.js | 19 +++++++++ C7 Arrays/ejercicios/24.js | 17 ++++++++ C7 Arrays/ejercicios/25.js | 13 ++++++ C7 Arrays/ejercicios/26.js | 12 +++++- C7 Arrays/ejercicios/27.js | 2 + C7 Arrays/ejercicios/28.js | 12 +++++- C7 Arrays/ejercicios/29.js | 17 +++++++- C7 Arrays/ejercicios/30.js | 12 +++++- C7 Arrays/ejercicios/31.js | 4 ++ C7 Arrays/ejercicios/32.js | 14 ++++++- C7 Arrays/ejercicios/33.js | 46 +++++++++++++++++++++- 34 files changed, 363 insertions(+), 10 deletions(-) diff --git a/C5 Fundamentos Javascript/ejercicios/18.js b/C5 Fundamentos Javascript/ejercicios/18.js index 680eaa8489..e5558b3af6 100644 --- a/C5 Fundamentos Javascript/ejercicios/18.js +++ b/C5 Fundamentos Javascript/ejercicios/18.js @@ -8,9 +8,9 @@ function esVocal(letra) { // "n" ---> "Dato incorrecto" // "texto largo" ---> "Dato incorrecto" // Tu código: - if (letra.length != 1){ - return ('Dato incorrecto') - } + //if (letra.length != 1){ + //return ('Dato incorrecto') + //} if(letra === 'a' || letra === 'e' || letra ==='i' || letra === 'o' || letra === 'u') { return ('Es vocal') diff --git a/C7 Arrays/ejercicios/01.js b/C7 Arrays/ejercicios/01.js index 508c5fd8a1..0c8e3abe00 100644 --- a/C7 Arrays/ejercicios/01.js +++ b/C7 Arrays/ejercicios/01.js @@ -1,6 +1,8 @@ function devolverPrimerElemento(array) { // Retornar el primer elemento del arreglo recibido. // Tu código: + return array[0] } module.exports = devolverPrimerElemento; + diff --git a/C7 Arrays/ejercicios/02.js b/C7 Arrays/ejercicios/02.js index 3c40692116..6dd4d4601b 100644 --- a/C7 Arrays/ejercicios/02.js +++ b/C7 Arrays/ejercicios/02.js @@ -1,6 +1,11 @@ function devolverUltimoElemento(array) { // Retornar el último elemento del arreglo recibido. // Tu código: + return array [array.length -1] } module.exports = devolverUltimoElemento; + +var array = [1,2,3,4] + +console.log(devolverUltimoElemento(array)) diff --git a/C7 Arrays/ejercicios/03.js b/C7 Arrays/ejercicios/03.js index 1170d0a120..16549656fd 100644 --- a/C7 Arrays/ejercicios/03.js +++ b/C7 Arrays/ejercicios/03.js @@ -1,6 +1,8 @@ function obtenerLargoDelArray(array) { // Retornar la longitud del arreglo recibido. // Tu código: + return array.length } module.exports = obtenerLargoDelArray; + diff --git a/C7 Arrays/ejercicios/04.js b/C7 Arrays/ejercicios/04.js index f8433b6134..45f8b35d8c 100644 --- a/C7 Arrays/ejercicios/04.js +++ b/C7 Arrays/ejercicios/04.js @@ -2,6 +2,10 @@ function agregarItemAlFinalDelArray(array, elemento) { // Agrega el "elemento" al final del arreglo recibido. // Retorna el arreglo. // Tu código: + var agregarElemento = array.push(elemento) + + return agregarElemento } module.exports = agregarItemAlFinalDelArray; + diff --git a/C7 Arrays/ejercicios/05.js b/C7 Arrays/ejercicios/05.js index 9d17508d9d..b38b48c1e2 100644 --- a/C7 Arrays/ejercicios/05.js +++ b/C7 Arrays/ejercicios/05.js @@ -2,6 +2,9 @@ function agregarItemAlComienzoDelArray(array, elemento) { // Agrega el "elemento" al comienzo del arreglo recibido. // Retorna el arreglo. // Tu código: + var agregarElemento = array.unshift(elemento) + + return agregarElemento } -module.exports = agregarItemAlComienzoDelArray; +module.exports = agregarItemAlComienzoDelArray; \ No newline at end of file diff --git a/C7 Arrays/ejercicios/06.js b/C7 Arrays/ejercicios/06.js index 0d093fec57..20b430c8b4 100644 --- a/C7 Arrays/ejercicios/06.js +++ b/C7 Arrays/ejercicios/06.js @@ -1,6 +1,22 @@ function invertirArray(array) { // Invierte el arreglo array recibido por argumento. // Tu código: + //MANERA RECURSIVA + + let invertirArray = [] + + for(let i = array.length - 1; i>=0 ; i--){ + invertirArray.push(array[i]) + } + + return invertirArray + //MANERA CON .REVERSE + //var invertirArray = array.reverse() + + //return invertirArray } module.exports = invertirArray; + +var array = [1,2,3,4,5] +console.log(invertirArray(array)) diff --git a/C7 Arrays/ejercicios/07.js b/C7 Arrays/ejercicios/07.js index ef9535455e..d8a2e005e1 100644 --- a/C7 Arrays/ejercicios/07.js +++ b/C7 Arrays/ejercicios/07.js @@ -2,6 +2,11 @@ function ordenarArray(array) { // Ordena los elementos del areglo array de menor a mayor. // Devuelve el arreglo resultante. // Tu código: + return array.sort() + return array.sort((a,b) => a - b) } module.exports = ordenarArray; + +var arreglo = [1,5,1,1,7,4,2,9,1] + console.log(ordenarArray(arreglo)) \ No newline at end of file diff --git a/C7 Arrays/ejercicios/08.js b/C7 Arrays/ejercicios/08.js index 46dcf9a08f..7fde4ea09a 100644 --- a/C7 Arrays/ejercicios/08.js +++ b/C7 Arrays/ejercicios/08.js @@ -3,6 +3,17 @@ function encontrarElemento(num, array) { // Si lo encuentras debes retornar el INDICE en el que se encuentra dentro del array. // Si no se encuentra, retorna -1. // Tu código: + var Elemento = array.findIndex(elemento => elemento === num) + + return elemento } module.exports = encontrarElemento; + + + + + + + + diff --git a/C7 Arrays/ejercicios/09.js b/C7 Arrays/ejercicios/09.js index 5f9b6248d8..5697fc75cb 100644 --- a/C7 Arrays/ejercicios/09.js +++ b/C7 Arrays/ejercicios/09.js @@ -2,6 +2,13 @@ function obtenerElementoAleatorio(array) { // Devuelve un elemento aleatorio del arreglo array. // PISTA: Usa el método Math.random(). // Tu código: + var verrandom = Math.random() + var elemento = Math.floor(Math.random() * array.length) + + console.log(verrandom) + return array[elemento] + } module.exports = obtenerElementoAleatorio; + diff --git a/C7 Arrays/ejercicios/10.js b/C7 Arrays/ejercicios/10.js index dea50da555..a246a7569c 100644 --- a/C7 Arrays/ejercicios/10.js +++ b/C7 Arrays/ejercicios/10.js @@ -1,6 +1,10 @@ function obtenerPrimerStringLargo(array) { // Devuelve el primer string con más de 5 caracteres en el array. // Tu código: + + return array.find(item => typeof item === 'string' && item.length > 5) || 'no hay' + } module.exports = obtenerPrimerStringLargo; + diff --git a/C7 Arrays/ejercicios/11.js b/C7 Arrays/ejercicios/11.js index 3194c62196..4c21bd74e9 100644 --- a/C7 Arrays/ejercicios/11.js +++ b/C7 Arrays/ejercicios/11.js @@ -2,6 +2,11 @@ function duplicarElementos(array) { // Duplica (multiplica x2) cada elemento del array de números. // Devuelve un array con los duplicados. // Tu código: + var porDos = array.map(num =>{ + return num * 2 + }) + + return porDos } module.exports = duplicarElementos; diff --git a/C7 Arrays/ejercicios/12.js b/C7 Arrays/ejercicios/12.js index 2df8d8eb7d..bfce75b42b 100644 --- a/C7 Arrays/ejercicios/12.js +++ b/C7 Arrays/ejercicios/12.js @@ -2,6 +2,16 @@ function convertirStringAMayusculas(array) { // Convierte a mayúsculas todos los strings del array. // Retorna el arreglo resultante. // Tu código: + var Mayus = array.map(num => { + if (typeof num === 'string'){ + return num.toUpperCase() + } else { + return num + } + }) + + return Mayus } module.exports = convertirStringAMayusculas; + diff --git a/C7 Arrays/ejercicios/13.js b/C7 Arrays/ejercicios/13.js index 037a01b1b9..02b45de341 100644 --- a/C7 Arrays/ejercicios/13.js +++ b/C7 Arrays/ejercicios/13.js @@ -1,6 +1,20 @@ function filtrarNumerosPares(array) { // Devuelve un arreglo solo con los números pares presentes en el array. // Tu código: + // var par = array.map(num => { + // if(num % 2 === 0){ + // return num + // } else { + // return false + // } + // }) + + // return par + + return array.filter (num => typeof num === 'number' && num % 2 === 0) || 'No hay pares' } module.exports = filtrarNumerosPares; + +let array = [2,4,5,7,8,20] +console.log(filtrarNumerosPares(array)) diff --git a/C7 Arrays/ejercicios/14.js b/C7 Arrays/ejercicios/14.js index 28cc42c259..ed06d458d4 100644 --- a/C7 Arrays/ejercicios/14.js +++ b/C7 Arrays/ejercicios/14.js @@ -1,6 +1,11 @@ function contarElementosMayoresA10(array) { // Cuenta y devuelve la cantidad de elementos mayores a 10 en el array de números. // Tu código: + + return array.filter(num => typeof num === 'number' && num > 10) || 'No hay elementos mayores a 10' } module.exports = contarElementosMayoresA10; + +let array = [1,3,4,5,70,83,12,45] +console.log(contarElementosMayoresA10(array)) diff --git a/C7 Arrays/ejercicios/15.js b/C7 Arrays/ejercicios/15.js index cf07316133..acd6dd275e 100644 --- a/C7 Arrays/ejercicios/15.js +++ b/C7 Arrays/ejercicios/15.js @@ -2,6 +2,15 @@ function encontrarIndiceMayor(array) { // Encuentra el índice del número más grande en el array de números. // Devuelve el valor de este índice. // Tu código: + //return array.filter(num => typeof num === 'number' && ) + let max = array[0] + + array.filter(num => { + if(num > max){ + max = num + } + }) } + module.exports = encontrarIndiceMayor; diff --git a/C7 Arrays/ejercicios/16.js b/C7 Arrays/ejercicios/16.js index 6e6019e704..33166b0ee3 100644 --- a/C7 Arrays/ejercicios/16.js +++ b/C7 Arrays/ejercicios/16.js @@ -2,6 +2,11 @@ function multiplicarElementosPorIndice(array) { // Multiplica cada elemento del array por su índice. // Devuelve el nuevo arreglo con los resultados. // Tu código: + let indice = array.map((item, index) => item * index) + + return indice } module.exports = multiplicarElementosPorIndice; +let array = [1,2,3,4,5] +console.log(multiplicarElementosPorIndice(array)) diff --git a/C7 Arrays/ejercicios/17.js b/C7 Arrays/ejercicios/17.js index edf8ab42f2..bac0c4d973 100644 --- a/C7 Arrays/ejercicios/17.js +++ b/C7 Arrays/ejercicios/17.js @@ -1,6 +1,11 @@ function agregarNumeros(arrayOfNums) { // Suma todos los elementos de arrayOfNums y retorna el resultado. // Tu código: + + return arrayOfNums.reduce((acumuludaor, sumador) => acumuludaor + sumador, 0) } module.exports = agregarNumeros; + +var array = [1,2,3,4] +console.log(agregarNumeros(array)) diff --git a/C7 Arrays/ejercicios/18.js b/C7 Arrays/ejercicios/18.js index 580e26c583..7ab2054de7 100644 --- a/C7 Arrays/ejercicios/18.js +++ b/C7 Arrays/ejercicios/18.js @@ -1,6 +1,15 @@ function promedioResultadosTest(resultadosTest) { // Itera sobre los elementos del arreglo resultadosTest y devuelve el promedio de las notas. // Tu código: + + const sumaTotal = resultadosTest.reduce((suma, cantidad) => suma + cantidad, 0) + + var promedio = sumaTotal / resultadosTest.length + + return promedio } module.exports = promedioResultadosTest; + +var notas = [1.5,2,3,4] +console.log(promedioResultadosTest(notas)) diff --git a/C7 Arrays/ejercicios/19.js b/C7 Arrays/ejercicios/19.js index 4aed7fecae..aeb8afcc93 100644 --- a/C7 Arrays/ejercicios/19.js +++ b/C7 Arrays/ejercicios/19.js @@ -3,6 +3,24 @@ function multiplicarArgumentos() { // Si no se pasan argumentos retorna 0. Si se pasa un argumento, simplemente retórnalo. // [PISTA]: "arguments" es un arreglo. // Tu código: + if(arguments.length === 0) { + return 0 + } + + if(arguments.length === 1){ + return arguments[0] + } + + let producto = 1 + + for(let i = 0; i < arguments.length; i++){ + producto *= arguments[i] + } + + return producto } module.exports = multiplicarArgumentos; + +var array = [1,2,3,4] +console.log(multiplicarArgumentos(1,2,3,4)) diff --git a/C7 Arrays/ejercicios/20.js b/C7 Arrays/ejercicios/20.js index bcce3a3dbc..b73ea45532 100644 --- a/C7 Arrays/ejercicios/20.js +++ b/C7 Arrays/ejercicios/20.js @@ -2,6 +2,20 @@ function todosIguales(array) { // Si todos los elementos del arreglo son iguales, retornar true. // Caso contrario, retornar false. // Tu código: + if (array.length <= 1){ + return false + } + + for (let i = 0; i 'Hello world!'. // Tu código: + return palabras.join('') + } module.exports = dePalabrasAFrase; diff --git a/C7 Arrays/ejercicios/28.js b/C7 Arrays/ejercicios/28.js index a1a65816b6..e289f7dfdd 100644 --- a/C7 Arrays/ejercicios/28.js +++ b/C7 Arrays/ejercicios/28.js @@ -3,6 +3,16 @@ function esArrayNoVacio(arr) { // Comprueba si este argumento es un array y si tiene al menos un elemento. // Si es así, retorna true, de lo contrario, retorna false. // Tu código: + if(Array.isArray(arr) && arr.length > 0){ + return true + } else if(typeof arr === 'string'){ + return false + } } -module.exports = esArrayNoVacio; \ No newline at end of file +module.exports = esArrayNoVacio; + +var arr = [1,2,3,4] +var arr1 = 'Sring' +var arr2 = 1 +console.log(esArrayNoVacio(arr2)) \ No newline at end of file diff --git a/C7 Arrays/ejercicios/29.js b/C7 Arrays/ejercicios/29.js index de8a058efa..38815958df 100644 --- a/C7 Arrays/ejercicios/29.js +++ b/C7 Arrays/ejercicios/29.js @@ -4,6 +4,21 @@ function encontrarNumeroFaltante(numeros) { // y retórnalo. // Devuelve null si el array es vacío o si no hay números faltantes. // Tu código: + if(numeros.length === 0){ + return null + } + + //0=3,1=5,2=6 + numeros.sort() + for(let i=0; i< numeros.length -1; i ++){ + if(numeros[i + 1] !== numeros[i] + 1 ){ + return numeros[i] + 1 + } + } + + return null } -module.exports = encontrarNumeroFaltante; \ No newline at end of file +module.exports = encontrarNumeroFaltante; +var array = [1,3,4] +console.log(encontrarNumeroFaltante(array)) \ No newline at end of file diff --git a/C7 Arrays/ejercicios/30.js b/C7 Arrays/ejercicios/30.js index 74cdb5570d..057a85a67d 100644 --- a/C7 Arrays/ejercicios/30.js +++ b/C7 Arrays/ejercicios/30.js @@ -2,6 +2,16 @@ function encontrarElementoRepetido(numeros) { // La función recibe un argumento "numeros" que es un array de números. // Retorna el primer elemento repetido que se encuentre en el array. // Tu código: + for(let i=0; i Date: Tue, 20 Aug 2024 19:20:58 -0500 Subject: [PATCH 5/9] C5 C7 --- C5 Fundamentos Javascript/ejercicios/12.js | 3 +++ C7 Arrays/ejercicios/10.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/C5 Fundamentos Javascript/ejercicios/12.js b/C5 Fundamentos Javascript/ejercicios/12.js index 4753c5ee57..8f5a6134ce 100644 --- a/C5 Fundamentos Javascript/ejercicios/12.js +++ b/C5 Fundamentos Javascript/ejercicios/12.js @@ -18,3 +18,6 @@ function tienenMismaLongitud(str1, str2) { module.exports = tienenMismaLongitud; + +var array = ['hola', 'puedo'] +console.log(tienenMismaLongitud('hola', 'pued')) diff --git a/C7 Arrays/ejercicios/10.js b/C7 Arrays/ejercicios/10.js index a246a7569c..3add69eff1 100644 --- a/C7 Arrays/ejercicios/10.js +++ b/C7 Arrays/ejercicios/10.js @@ -8,3 +8,6 @@ function obtenerPrimerStringLargo(array) { module.exports = obtenerPrimerStringLargo; +var array = ['hola', 'hello1'] +console.log(obtenerPrimerStringLargo(array)) + From 8972daf0e130601beca89139582a96d33cded061 Mon Sep 17 00:00:00 2001 From: Gomez1028 Date: Thu, 22 Aug 2024 00:00:40 -0500 Subject: [PATCH 6/9] c8 --- C7 Arrays/ejercicios/15.js | 7 ++++++ .../objects/ejercicios/01.js | 4 ++++ .../objects/ejercicios/02.js | 11 +++++++++ .../objects/ejercicios/03.js | 8 +++++++ .../objects/ejercicios/04.js | 7 ++++++ .../objects/ejercicios/05.js | 7 ++++++ .../objects/ejercicios/06.js | 11 +++++++++ .../objects/ejercicios/07.js | 15 ++++++++++++ .../objects/ejercicios/08.js | 14 +++++++++++ .../objects/ejercicios/09.js | 10 ++++++++ .../objects/ejercicios/10.js | 7 ++++++ .../objects/ejercicios/11.js | 14 +++++++++++ .../objects/ejercicios/12.js | 8 +++++++ .../objects/ejercicios/13.js | 6 +++++ .../objects/ejercicios/14.js | 9 +++++++ .../objects/ejercicios/15.js | 8 +++++++ .../objects/ejercicios/16.js | 20 ++++++++++++++++ .../objects/ejercicios/17.js | 8 +++++++ .../objects/ejercicios/18.js | 24 +++++++++++++++++++ .../objects/ejercicios/19.js | 17 +++++++++++++ .../objects/ejercicios/20.js | 18 ++++++++++++++ .../objects/ejercicios/21.js | 18 ++++++++++++++ .../objects/ejercicios/22.js | 3 +++ 23 files changed, 254 insertions(+) diff --git a/C7 Arrays/ejercicios/15.js b/C7 Arrays/ejercicios/15.js index acd6dd275e..e886741ab2 100644 --- a/C7 Arrays/ejercicios/15.js +++ b/C7 Arrays/ejercicios/15.js @@ -3,14 +3,21 @@ function encontrarIndiceMayor(array) { // Devuelve el valor de este índice. // Tu código: //return array.filter(num => typeof num === 'number' && ) + let max = array[0] + array.filter(num => { if(num > max){ max = num } }) +//2 + return max } module.exports = encontrarIndiceMayor; + +var array = [1,2,3,4,6] +console.log(encontrarIndiceMayor(array)) diff --git a/C8 Objects + Callbacks/objects/ejercicios/01.js b/C8 Objects + Callbacks/objects/ejercicios/01.js index 4e28b4c584..8e1d03fabe 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/01.js +++ b/C8 Objects + Callbacks/objects/ejercicios/01.js @@ -8,3 +8,7 @@ const obtenerValorPropiedad = (objeto, propiedad) => { }; module.exports = obtenerValorPropiedad; + +var carro = {nombre: 'Fabio'} + +console.log(obtenerValorPropiedad(carro, 'nombre')) \ No newline at end of file diff --git a/C8 Objects + Callbacks/objects/ejercicios/02.js b/C8 Objects + Callbacks/objects/ejercicios/02.js index fd81338de0..7eed177736 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/02.js +++ b/C8 Objects + Callbacks/objects/ejercicios/02.js @@ -2,8 +2,19 @@ function actualizarValorPropiedad(objeto, propiedad, valor) { // Actualiza el valor de la propiedad del objeto recibidos en la función. // Retorna el objeto actualizado. // Tu código: + // Correcto: usando Bracket Notation para acceder a una propiedad dinámica objeto[propiedad] = valor; + + // Incorrecto: esto crearía una propiedad literal llamada 'propiedad' + // objeto.propiedad = valor; + //Dot notation se utiliza cuando se sabe el nombre de la propiedad y queremos actualizarla return objeto; } module.exports = actualizarValorPropiedad; + +var carro = {nombre: 'BMW', km: 6000, estado: 'Semi Nuevo'} + +console.log(actualizarValorPropiedad(carro, 'nombre', 'Ferrari')) + + diff --git a/C8 Objects + Callbacks/objects/ejercicios/03.js b/C8 Objects + Callbacks/objects/ejercicios/03.js index 9705c17350..b8e899032f 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/03.js +++ b/C8 Objects + Callbacks/objects/ejercicios/03.js @@ -1,6 +1,14 @@ const agregarNuevaPropiedad = (objeto, propiedad, valor) => { // Añade una nueva propiedad al objeto con su respectivo valor pasado por la función. // Tu código: + objeto[propiedad] = valor + + return objeto }; module.exports = agregarNuevaPropiedad; + +var carro = {nombre: 'BMW', km: 6000, estado: 'Semi Nuevo'} + +console.log(agregarNuevaPropiedad(carro, 'llantas', 'nuevas')) + diff --git a/C8 Objects + Callbacks/objects/ejercicios/04.js b/C8 Objects + Callbacks/objects/ejercicios/04.js index 8dbc773948..d1dfe56ba7 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/04.js +++ b/C8 Objects + Callbacks/objects/ejercicios/04.js @@ -3,6 +3,13 @@ function verificarPropiedad(objeto, propiedad) { // Retorna true si la tiene, sino retorna false. // PISTA: puedes usar el método hasOwnProperty(). // Tu código: + var tienePropiedad = objeto.hasOwnProperty(propiedad) + + return tienePropiedad } module.exports = verificarPropiedad; + +var carro = {nombre: 'BMW', km: 6000, estado: 'Semi Nuevo'} + +console.log(verificarPropiedad(carro, 'color')) diff --git a/C8 Objects + Callbacks/objects/ejercicios/05.js b/C8 Objects + Callbacks/objects/ejercicios/05.js index 57485922a9..af5ed5916a 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/05.js +++ b/C8 Objects + Callbacks/objects/ejercicios/05.js @@ -2,6 +2,13 @@ const listarPropiedades = (objeto) => { // Lista y retorna todas las propiedades que posee el objeto recibido por la función. // PISTA: Puedes usar el método Object.keys(). // Tu código: + var MostrarPropiedades = Object.keys(objeto) + + return MostrarPropiedades }; module.exports = listarPropiedades; + +var carro = {nombre: 'BMW', km: 6000, estado: 'Semi Nuevo'} + +console.log(listarPropiedades(carro)) diff --git a/C8 Objects + Callbacks/objects/ejercicios/06.js b/C8 Objects + Callbacks/objects/ejercicios/06.js index da96759653..198ce6e91b 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/06.js +++ b/C8 Objects + Callbacks/objects/ejercicios/06.js @@ -2,6 +2,17 @@ const contarPropiedades = (objeto) => { // Cuenta y retorna el total de propiedades que tiene el objeto. // PISTA: Puedes iterarlo usando el bucle for-in. // Tu código: + let sumador = 0 + + for(let prop in objeto){ + sumador ++ + } + + return sumador }; module.exports = contarPropiedades; + +var carro = {nombre: 'BMW', km: 6000, estado: 'Semi Nuevo'} + +console.log(contarPropiedades(carro)) diff --git a/C8 Objects + Callbacks/objects/ejercicios/07.js b/C8 Objects + Callbacks/objects/ejercicios/07.js index 38b33c7db6..48177f7479 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/07.js +++ b/C8 Objects + Callbacks/objects/ejercicios/07.js @@ -7,6 +7,21 @@ function sort(sortBy, list) { // recibes --> ("a", [{ a: 1, b: 3 }, { a: 3, b: 2 }, { a: 2, b: 40 }]) // retorna --> [{ a: 3, b: 2 }, { a: 2, b: 40 }, { a: 1, b: 3 }] // Tu código: + + return list.sort((obj1,obj2) => { + return obj2[sortBy] - obj1[sortBy] + }) } module.exports = sort; + +var carro = {nombre: 'BMW', km: 6000, estado: 'Semi Nuevo'} +const list = [ + { a: 1, b: 3 }, + { a: 3, b: 2 }, + { a: 2, b: 40 } + ]; +console.log(sort('a', list)) + + + diff --git a/C8 Objects + Callbacks/objects/ejercicios/08.js b/C8 Objects + Callbacks/objects/ejercicios/08.js index b6915259c4..1aeee111ba 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/08.js +++ b/C8 Objects + Callbacks/objects/ejercicios/08.js @@ -5,6 +5,20 @@ function crearGato(nombre, edad) { // La propiedad "meow" será una función que retorne el string: "Meow!". // Retornar el objeto. // Tu código: + var gato = { + Nombre: nombre, + Edad: edad, + meow: function(){ + return ('Meow!') + } + } + + return gato } module.exports = crearGato; + +const migato = crearGato('Sox', 2) + +console.log(migato.Nombre) +console.log(migato.meow()) diff --git a/C8 Objects + Callbacks/objects/ejercicios/09.js b/C8 Objects + Callbacks/objects/ejercicios/09.js index ff0b379077..21f8c04e21 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/09.js +++ b/C8 Objects + Callbacks/objects/ejercicios/09.js @@ -3,6 +3,16 @@ function nuevoUsuario(nombre, email, password) { // Este debe tener las propiedades: "nombre", "email" y "password" con sus respectivos valores. // Retorna el objeto creado. // Tu código: + var cliente = { + nombre: nombre, + email: email, + password: password, + } + + return cliente } module.exports = nuevoUsuario; + +var cliente = nuevoUsuario('Fabio', 'fabioandfe@gm.oc', 'password') +console.log(cliente.nombre) diff --git a/C8 Objects + Callbacks/objects/ejercicios/10.js b/C8 Objects + Callbacks/objects/ejercicios/10.js index b307e660e3..4ec9df184c 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/10.js +++ b/C8 Objects + Callbacks/objects/ejercicios/10.js @@ -4,6 +4,13 @@ function agregarPropiedad(objeto, propiedad) { // Esta propiedad será igual al valor `null`. // Retornar el objeto. // Tu código: + objeto[propiedad] = null + + return objeto } module.exports = agregarPropiedad; + +var carro = {nombre: 'BMW', km: 6000, estado: 'Semi Nuevo'} + +console.log(agregarPropiedad(carro, 'como')) diff --git a/C8 Objects + Callbacks/objects/ejercicios/11.js b/C8 Objects + Callbacks/objects/ejercicios/11.js index 85579d0d92..f44459325d 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/11.js +++ b/C8 Objects + Callbacks/objects/ejercicios/11.js @@ -3,6 +3,20 @@ function invocarMetodo(objeto, metodo) { // Esta propiedad contiene una función en su interior. Debes invocarla/ejecutarla. // NOTA: no necesitas retornar nada. // Tu código: + objeto[metodo]() + + return objeto } module.exports = invocarMetodo; + +var carro = { + nombre: 'BMW', + km: 6000, + estado: 'Semi Nuevo', + saludar: function(){ + console.log('Hola me llamo ' + this.nombre) + } +} + +invocarMetodo(carro, 'saludar') diff --git a/C8 Objects + Callbacks/objects/ejercicios/12.js b/C8 Objects + Callbacks/objects/ejercicios/12.js index 976cd317d3..ed3a2f8692 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/12.js +++ b/C8 Objects + Callbacks/objects/ejercicios/12.js @@ -2,6 +2,14 @@ function multiplicarNumeroDesconocidoPorCinco(objetoMisterioso) { // El parámetro "objetoMisterioso" posee una propiedad con el nombre "numeroMisterioso". // Debes multiplicar este número por 5 y retornar el resultado. // Tu código: + if(typeof objetoMisterioso['numeroMisterioso'] === 'number'){ + return objetoMisterioso['numeroMisterioso'] * 5 + } else { + return 'No es un numero' + } } module.exports = multiplicarNumeroDesconocidoPorCinco; + +var carro = {numeroMisterioso: 5} +console.log(multiplicarNumeroDesconocidoPorCinco(carro)) diff --git a/C8 Objects + Callbacks/objects/ejercicios/13.js b/C8 Objects + Callbacks/objects/ejercicios/13.js index 26b71ad81e..c29011ea96 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/13.js +++ b/C8 Objects + Callbacks/objects/ejercicios/13.js @@ -2,6 +2,12 @@ function eliminarPropiedad(objeto, propiedad) { // El parámetro "propiedad" es una propiedad del objeto que recibes. // Debes eliminarla del objeto y retornarlo finalmente. // Tu código: + delete objeto[propiedad] + + return objeto } module.exports = eliminarPropiedad; + +var carro = {nombre: 'BMW', km: 6000, estado: 'Semi Nuevo'} +console.log(eliminarPropiedad(carro, 'nombre')) diff --git a/C8 Objects + Callbacks/objects/ejercicios/14.js b/C8 Objects + Callbacks/objects/ejercicios/14.js index 21b96699d2..6f434c569c 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/14.js +++ b/C8 Objects + Callbacks/objects/ejercicios/14.js @@ -2,6 +2,15 @@ function tieneEmail(objetoUsuario) { // Verifica si el "objetoUsuario", en su propiedad "email", posee un valor definido. // En ese caso, retorna true. Caso contrario, false. // Tu código: + if(objetoUsuario.hasOwnProperty('email')){ + return true + } else { + return false + } } module.exports = tieneEmail; + +var carro = {nombre: 'BMW', email: 6000, estado: 'Semi Nuevo'} + +console.log(tieneEmail(carro)) diff --git a/C8 Objects + Callbacks/objects/ejercicios/15.js b/C8 Objects + Callbacks/objects/ejercicios/15.js index 9fe787b8fb..adba3e655d 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/15.js +++ b/C8 Objects + Callbacks/objects/ejercicios/15.js @@ -2,6 +2,14 @@ function tienePropiedad(objeto, propiedad) { // Verifica si el objeto recibido posee una propiedad con el mismo nombre que el parámetro "propiedad". // En ese caso, retorna true. Caso contrario, false. // Tu código: + if(objeto.hasOwnProperty(propiedad)){ + return true + } else { + return false + } } module.exports = tienePropiedad; + +var carro = {nombre: 'BMW', km: 6000, estado: 'Semi Nuevo', propiedad: 'hola'} +console.log(tienePropiedad(carro, 'propiedad')) \ No newline at end of file diff --git a/C8 Objects + Callbacks/objects/ejercicios/16.js b/C8 Objects + Callbacks/objects/ejercicios/16.js index 27c5dd2f47..3749233b55 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/16.js +++ b/C8 Objects + Callbacks/objects/ejercicios/16.js @@ -2,6 +2,26 @@ function verificarPassword(objetoUsuario, password) { // Verifica si la propiedad "password" del "objetoUsuario" coincide con el parámetro "password". // En ese caso, retorna true. Caso contrario, false. // Tu código: + + //TODAS ESTAS MANERAS ESTAN CORRECTAS + //return password in objetoUsuario + + //return objetoUsuario.hasOwnProperty(password) + + // if(password in objetoUsuario){ + // return true + // } else { + // return false + // } + + if(objetoUsuario.hasOwnProperty(password)){ + return true + } else { + return false + } } module.exports = verificarPassword; + +var carro = {nombre: 'BMW', km: 6000, estado: 'Semi Nuevo', propiedad: 'hola', password: 'gfgd'} +console.log(verificarPassword(carro, 'password')) diff --git a/C8 Objects + Callbacks/objects/ejercicios/17.js b/C8 Objects + Callbacks/objects/ejercicios/17.js index acdbae5590..b4e2461e11 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/17.js +++ b/C8 Objects + Callbacks/objects/ejercicios/17.js @@ -3,6 +3,14 @@ function actualizarPassword(objetoUsuario, nuevaPassword) { // La nueva contraseña la recibes por parámetro. // Retornar el objeto. // Tu código: + + objetoUsuario['password'] = nuevaPassword + + return objetoUsuario } module.exports = actualizarPassword; + +var carro = {nombre: 'BMW', km: 6000, estado: 'Semi Nuevo', propiedad: 'hola'} + +console.log(actualizarPassword(carro, 'hola')) diff --git a/C8 Objects + Callbacks/objects/ejercicios/18.js b/C8 Objects + Callbacks/objects/ejercicios/18.js index 1af064c1bf..2a8a6014a2 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/18.js +++ b/C8 Objects + Callbacks/objects/ejercicios/18.js @@ -3,6 +3,30 @@ function agregarAmigo(objetoUsuario, nuevoAmigo) { // Debes agregar el "nuevoAmigo" al final de este arreglo. // Retornar el objeto. // Tu código: + + if(objetoUsuario.hasOwnProperty('amigos')){ + objetoUsuario['amigos'].push(nuevoAmigo) + }else { + return 'No hay propiedad amigos' + } + // if(Array.isArray(objetoUsuario['amigos'])){ + // objetoUsuario['amigos'].push(nuevoAmigo) + // } else { + // return 'No hay propiedad amigos' + // } + //objetoUsuario['amigos'].push(nuevoAmigo) + + return objetoUsuario } module.exports = agregarAmigo; + +var carro = { + nombre: 'BMW', + km: 6000, + estado: 'Semi Nuevo', + propiedad: 'hola', + password: 'gfgd', + amigos: ['maria'] +} +console.log(agregarAmigo(carro, 'fabio')) diff --git a/C8 Objects + Callbacks/objects/ejercicios/19.js b/C8 Objects + Callbacks/objects/ejercicios/19.js index ccf3d4db4f..249f9d7a23 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/19.js +++ b/C8 Objects + Callbacks/objects/ejercicios/19.js @@ -4,6 +4,23 @@ function pasarUsuarioAPremium(objetoMuchosUsuarios) { // Define esta propiedad de todos los usuarios como true. // Retornar el arreglo. // Tu código: + for(let i = 0; i< objetoMuchosUsuarios.length; i++){ + if(objetoMuchosUsuarios[i].hasOwnProperty('esPremium')){ + objetoMuchosUsuarios[i]['esPremium'] = true + } else { + return 'No existe la propiedad' + } + } + return objetoMuchosUsuarios } module.exports = pasarUsuarioAPremium; + +var usuarios = [ + {nombre: 'Fabio', edad: 21, esPremium: false}, + {nombre: 'Camila', edad: 19, esPremium: false} +] + +console.log(pasarUsuarioAPremium(usuarios)) + +console.log(usuarios[0]['esPremium']) diff --git a/C8 Objects + Callbacks/objects/ejercicios/20.js b/C8 Objects + Callbacks/objects/ejercicios/20.js index b2ed3cce78..9c6405c3e0 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/20.js +++ b/C8 Objects + Callbacks/objects/ejercicios/20.js @@ -4,6 +4,24 @@ function sumarLikesDeUsuario(objetoUsuario) { // Cada post posee una propiedad llamada "likes". Esta propiedad es un número. // Debes sumar los likes de todos los post y retornar el resultado. // Tu código: + let sumador = 0 + + for(let i = 0; i 0.2 // Precio final ---> 8 // Tu código: + + objetoProducto['calcularPrecioDescuento'] = function(){ + const descuento = this.precio * this.porcentajeDeDescuento + const precioTotal = this.precio - descuento + + return precioTotal + } + + return objetoProducto } module.exports = agregarMetodoCalculoDescuento; + +var precio = { + precio: 10 , + porcentajeDeDescuento: 0.5 +} +var precioTotal = agregarMetodoCalculoDescuento(precio) +console.log(precioTotal.calcularPrecioDescuento()) + + diff --git a/C8 Objects + Callbacks/objects/ejercicios/22.js b/C8 Objects + Callbacks/objects/ejercicios/22.js index f14b686ac4..258b802e77 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/22.js +++ b/C8 Objects + Callbacks/objects/ejercicios/22.js @@ -5,6 +5,9 @@ function esAnagrama(str1, str2) { // IMPORTANTE: Un anagrama es una palabra que se forma // con las mismas letras que otra, pero en orden diferente. // Tu código: + return str1.split().sort().join() === str2.split().sort().join() } module.exports = esAnagrama; + +console.log(esAnagrama('roma', 'apple')) From f6892720babefc0bc9e1a2e1ec4bf18976f49c0f Mon Sep 17 00:00:00 2001 From: Gomez1028 Date: Thu, 22 Aug 2024 10:10:39 -0500 Subject: [PATCH 7/9] Tarea callbacks --- C7 Arrays/ejercicios/10.js | 8 +++++++- C8 Objects + Callbacks/callbacks/ejercicios/01.js | 2 ++ C8 Objects + Callbacks/callbacks/ejercicios/02.js | 12 ++++++++++++ C8 Objects + Callbacks/callbacks/ejercicios/03.js | 8 ++++++++ C8 Objects + Callbacks/callbacks/ejercicios/04.js | 10 ++++++++++ C8 Objects + Callbacks/objects/ejercicios/11.js | 2 +- 6 files changed, 40 insertions(+), 2 deletions(-) diff --git a/C7 Arrays/ejercicios/10.js b/C7 Arrays/ejercicios/10.js index 3add69eff1..dd34142239 100644 --- a/C7 Arrays/ejercicios/10.js +++ b/C7 Arrays/ejercicios/10.js @@ -1,8 +1,14 @@ function obtenerPrimerStringLargo(array) { // Devuelve el primer string con más de 5 caracteres en el array. // Tu código: + for(let i= 0; i<= array.length; i++){ + if(array[i].length >= 5){ + return array[i] + } + } + return 'No hay' - return array.find(item => typeof item === 'string' && item.length > 5) || 'no hay' + //return array.find(item => typeof item === 'string' && item.length > 5) || 'no hay' } diff --git a/C8 Objects + Callbacks/callbacks/ejercicios/01.js b/C8 Objects + Callbacks/callbacks/ejercicios/01.js index 9540c6b3b2..a2282e2833 100644 --- a/C8 Objects + Callbacks/callbacks/ejercicios/01.js +++ b/C8 Objects + Callbacks/callbacks/ejercicios/01.js @@ -2,6 +2,8 @@ function invocarCallback(cb) { // Invoca/ejecuta el callback `cb`. // NOTA: no debes retornar nada. // Tu código: + cb() } module.exports = invocarCallback; + diff --git a/C8 Objects + Callbacks/callbacks/ejercicios/02.js b/C8 Objects + Callbacks/callbacks/ejercicios/02.js index df7a401ef8..fb7def06b6 100644 --- a/C8 Objects + Callbacks/callbacks/ejercicios/02.js +++ b/C8 Objects + Callbacks/callbacks/ejercicios/02.js @@ -3,6 +3,18 @@ function cambiarCadena(string, callback) { // La función de callback se encargará de recibir el string y devolverlo con los cambios. // Si no se recibe una función callback entonces se debe retornar el string original. // Tu código: + if(typeof callback === 'function'){ + return callback(string) + } else { + return string + } } +function aMayus(string) { + return string.toUpperCase() +} + +var completo = cambiarCadena('Hola como vas', aMayus) +console.log(completo) + module.exports = cambiarCadena; diff --git a/C8 Objects + Callbacks/callbacks/ejercicios/03.js b/C8 Objects + Callbacks/callbacks/ejercicios/03.js index 767f0a1808..d2416a6986 100644 --- a/C8 Objects + Callbacks/callbacks/ejercicios/03.js +++ b/C8 Objects + Callbacks/callbacks/ejercicios/03.js @@ -3,6 +3,14 @@ function operacionMatematica(num1, num2, cb) { // El callback realiza una operación matemática, por lo que necesita de los dos números. // Retorna el resultado del callback pasándole por valores los números num1 y num2. // Tu código: + return cb(num1, num2) } +function sumador(num1, num2){ + return num1 + num2 +} + +var total = (operacionMatematica(1,2,sumador)) +console.log(total) + module.exports = operacionMatematica; diff --git a/C8 Objects + Callbacks/callbacks/ejercicios/04.js b/C8 Objects + Callbacks/callbacks/ejercicios/04.js index 04f18b1ec5..d117cc6bbd 100644 --- a/C8 Objects + Callbacks/callbacks/ejercicios/04.js +++ b/C8 Objects + Callbacks/callbacks/ejercicios/04.js @@ -4,6 +4,16 @@ function sumarArray(arrayOfNumbers, cb) { // Este resultado debes pasárselo como argumento al callback recibido. // NOTA: no debes retornar nada. // Tu código: + var sumaTtotal = arrayOfNumbers.reduce((suma, valorActual)=> suma + valorActual,0) + return cb(sumaTtotal) } +function verSuma(cb){ + return ('la suma total es ' + cb) +} + +const arreglo = [1,2,3,4] + +console.log(sumarArray(arreglo, verSuma)) + module.exports = sumarArray; diff --git a/C8 Objects + Callbacks/objects/ejercicios/11.js b/C8 Objects + Callbacks/objects/ejercicios/11.js index f44459325d..6a66f195b9 100644 --- a/C8 Objects + Callbacks/objects/ejercicios/11.js +++ b/C8 Objects + Callbacks/objects/ejercicios/11.js @@ -5,7 +5,7 @@ function invocarMetodo(objeto, metodo) { // Tu código: objeto[metodo]() - return objeto + //return objeto } module.exports = invocarMetodo; From adbe1e6ed1939703a04706a6c6612d191a6f6cd0 Mon Sep 17 00:00:00 2001 From: Gomez1028 Date: Thu, 22 Aug 2024 10:34:10 -0500 Subject: [PATCH 8/9] tarea hoy --- C8 Objects + Callbacks/callbacks/ejercicios/05.js | 10 ++++++++++ C8 Objects + Callbacks/objects/ejercicios/11.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/C8 Objects + Callbacks/callbacks/ejercicios/05.js b/C8 Objects + Callbacks/callbacks/ejercicios/05.js index cecc94504d..bb20c1c8f6 100644 --- a/C8 Objects + Callbacks/callbacks/ejercicios/05.js +++ b/C8 Objects + Callbacks/callbacks/ejercicios/05.js @@ -2,6 +2,16 @@ function forEach(array, cb) { // Recibes un arreglo y un callback. // Itera sobre el arreglo y por cada elemento iterado, ejecuta el callback con este valor. // Tu código: + for(let i=0; i Date: Thu, 22 Aug 2024 23:33:35 -0500 Subject: [PATCH 9/9] Ejercicios extras --- C7 Arrays/ejercicios/09.js | 5 +- .../callbacks/ejercicios/05.js | 7 +- .../callbacks/ejercicios/06.js | 14 +++ .../callbacks/ejercicios/07.js | 16 +++ .../callbacks/ejercicios/08.js | 14 +++ C9 Ejercicios Extra/Ejercicios Extra.js | 101 ++++++++++++++++++ 6 files changed, 153 insertions(+), 4 deletions(-) diff --git a/C7 Arrays/ejercicios/09.js b/C7 Arrays/ejercicios/09.js index 5697fc75cb..d06adda0d1 100644 --- a/C7 Arrays/ejercicios/09.js +++ b/C7 Arrays/ejercicios/09.js @@ -3,7 +3,7 @@ function obtenerElementoAleatorio(array) { // PISTA: Usa el método Math.random(). // Tu código: var verrandom = Math.random() - var elemento = Math.floor(Math.random() * array.length) + var elemento = Math.floor(verrandom * array.length) console.log(verrandom) return array[elemento] @@ -11,4 +11,7 @@ function obtenerElementoAleatorio(array) { } module.exports = obtenerElementoAleatorio; +var array = [1,2,3,4] +console.log(obtenerElementoAleatorio(array)) + diff --git a/C8 Objects + Callbacks/callbacks/ejercicios/05.js b/C8 Objects + Callbacks/callbacks/ejercicios/05.js index bb20c1c8f6..29d6c398fc 100644 --- a/C8 Objects + Callbacks/callbacks/ejercicios/05.js +++ b/C8 Objects + Callbacks/callbacks/ejercicios/05.js @@ -2,16 +2,17 @@ function forEach(array, cb) { // Recibes un arreglo y un callback. // Itera sobre el arreglo y por cada elemento iterado, ejecuta el callback con este valor. // Tu código: + for(let i=0; i { // Si el elemento no se encuentra, devuelve el mensje "No se encontró el elemento". // La función de callback es la encargada de evaluar si el elemento fue encontrado. // Tu código: + + for(let i=0; i [['D', 1], ['B', 2], ['C', 3]]. // Tu código: + return Object.entries(objeto) } +var objeto = {D: 1, B: 2, C: 3} +console.log(deObjetoAarray(objeto)) + function numberOfCharacters(string) { // La función recibe un string. Debes recorrerlo y retornar un objeto donde cada propiedad es una de las // letras del string, y su valor es la cantidad de veces que se repite en el string. // Las letras deben estar en orden alfabético. // [EJEMPLO]: "adsjfdsfsfjsdjfhacabcsbajda" ---> { a: 5, b: 2, c: 2, d: 4, f: 4, h:1, j: 4, s: 5 } // Tu código: + let contador = {} + + for(let i=0; i { + objetoOrdenado[letra] = contador[letra] + })) + + return contador + } +var strin = "adsjfdsfsfjsdjfhacabcsbajda" +console.log(numberOfCharacters(strin)) + function capToFront(string) { // Recibes un string con algunas letras en mayúscula y otras en minúscula. // Debes enviar todas las letras en mayúscula al comienzo del string. // Retornar el string. // [EJEMPLO]: soyHENRY ---> HENRYsoy // Tu código: + let mayus = [] + let minu = [] + + for(let i=0; i "ehT yrneH egnellahC si !esolc" // Tu código: + let nuevoArray = [] + + let frasePartida = frase.split(' ') + + for(let i=0; i [“You", "are", "looking", "beautiful"] // Tu código: + return arrayOfStrings.sort((a,b) => a.length - b.length) } +var array = ["You", "are", "beautiful", "looking"] +console.log(sortArray(array)) + function buscoInterseccion(array1, array2) { // Recibes dos arreglos de números. // Debes retornar un nuevo arreglo en el que se guarden los elementos en común entre ambos arreglos. @@ -58,8 +145,22 @@ function buscoInterseccion(array1, array2) { // Si no tienen elementos en común, retornar un arreglo vacío. // [PISTA]: los arreglos no necesariamente tienen la misma longitud. // Tu código: + let nuevoArray = [] + + for(let i=0; i