diff --git a/02-JS-I/homework/homework.js b/02-JS-I/homework/homework.js index 3c92ac9cdf..9abc05f4a6 100644 --- a/02-JS-I/homework/homework.js +++ b/02-JS-I/homework/homework.js @@ -1,22 +1,22 @@ // En estas primeras 6 preguntas, reemplaza `null` por la respuesta // Crea una variable "string", puede contener lo que quieras: -const nuevaString = null; +const nuevaString = "string"; // Crea una variable numérica, puede ser cualquier número: -const nuevoNum = null; +const nuevoNum = 15; // Crea una variable booleana: -const nuevoBool = null; +const nuevoBool = true; // Resuelve el siguiente problema matemático: -const nuevaResta = 10 - null === 5; +const nuevaResta = 10 - 5 === 5; // Resuelve el siguiente problema matemático: -const nuevaMultiplicacion = 10 * null === 40 ; +const nuevaMultiplicacion = 10 * 4 === 40 ; // Resuelve el siguiente problema matemático: -const nuevoModulo = 21 % 5 === null; +const nuevoModulo = 21 % 5 === 1; // En los próximos 22 problemas, deberás completar la función. @@ -74,20 +74,28 @@ function menosQueNoventa(num) { // Devuelve "true" si el argumento de la función "num" es menor que noventa // De lo contrario, devuelve "false" // Tu código: - + if (90 > num) { + return true; + } + return false; + } function mayorQueCincuenta(num) { // Devuelve "true" si el argumento de la función "num" es mayor que cincuenta // De lo contrario, devuelve "false" // Tu código: - + if (50 < num) { + return true; + } + return false; } function obtenerResto(x, y) { // Obten el resto de la división de "x" entre "y" // Tu código: - + return x % y ; + } function esPar(num) { @@ -95,12 +103,19 @@ function esPar(num) { // De lo contrario, devuelve "false" // Tu código: +} + return false; } function esImpar(num) { // Devuelve "true" si "num" es impar // De lo contrario, devuelve "false" // Tu código: + if( num %2 == 1){ + return true; + + } + return false; } @@ -108,37 +123,38 @@ function elevarAlCuadrado(num) { // Devuelve el valor de "num" elevado al cuadrado // ojo: No es raiz cuadrada! // Tu código: - + return Math.pow(num,2); } function elevarAlCubo(num) { // Devuelve el valor de "num" elevado al cubo // Tu código: - + return Math.pow(num,3); } function elevar(num, exponent) { // Devuelve el valor de "num" elevado al exponente dado en "exponent" // Tu código: - + return Math.pow(num,exponent); } function redondearNumero(num) { // Redondea "num" al entero más próximo y devuélvelo // Tu código: - + return Math.round(num); } function redondearHaciaArriba(num) { // Redondea "num" hacia arriba (al próximo entero) y devuélvelo // Tu código: - + return Math.ceil(num); } function numeroRandom() { //Generar un número al azar entre 0 y 1 y devolverlo //Pista: investigá qué hace el método Math.random() - + var numero=Math.random(); + return numero; } function esPositivo(numero) { @@ -146,46 +162,66 @@ function esPositivo(numero) { //Si el número es positivo, devolver ---> "Es positivo" //Si el número es negativo, devolver ---> "Es negativo" //Si el número es 0, devuelve false - -} + if(numero === 0){ + + return false; + + }else if(numero > 0) { + + return("Es positivo"); + + }else{ + + return("Es negativo"); + + }; + +}; function agregarSimboloExclamacion(str) { // Agrega un símbolo de exclamación al final de la string "str" y devuelve una nueva string - // Ejemplo: "hello world" pasaría a ser "hello world!" + // Ejemplo: "hello world" pasaría a ser "hello world!" // Tu código: + return str + "!"; } function combinarNombres(nombre, apellido) { // Devuelve "nombre" y "apellido" combinados en una string y separados por un espacio. // Ejemplo: "Soy", "Henry" -> "Soy Henry" // Tu código: - + var combi = nombre + " "+ apellido; + return combi; + } function obtenerSaludo(nombre) { // Toma la string "nombre" y concatena otras string en la cadena para que tome la siguiente forma: // "Martin" -> "Hola Martin!" // Tu código: - + var frase = `Hola ${nombre}!`; + return frase; + } function obtenerAreaRectangulo(alto, ancho) { // Retornar el area de un rectángulo teniendo su altura y ancho // Tu código: - + + return ancho * alto; } function retornarPerimetro(lado){ //Escibe una función a la cual reciba el valor del lado de un cuadrado y retorne su perímetro. //Escribe tu código aquí - + return lado * 4; } function areaDelTriangulo(base, altura){ //Desarrolle una función que calcule el área de un triángulo. //Escribe tu código aquí + return (base * altura) /2; } @@ -194,7 +230,7 @@ function deEuroAdolar(euro){ //Supongamos que 1 euro equivale a 1.20 dólares. Escribe un programa que reciba //como parámetro un número de euros y calcule el cambio en dólares. //Escribe tu código aquí - + return euro * 1.20; } @@ -204,7 +240,14 @@ function esVocal(letra){ //que no se puede procesar el dato mediante el mensaje "Dato incorrecto". // Si no es vocal, tambien debe devolver "Dato incorrecto". //Escribe tu código aquí - + if(letra.length > 1){ + return "Dato incorrecto"; + } + if(letra === "a" || letra === "e" || letra === "i" || letra === "o" || letra === "u"){ + return "Es vocal"; + } + return "Dato incorrecto"; + } diff --git a/06-JS-V/homework/homework.js b/06-JS-V/homework/homework.js index f7910b373e..3aa42a8207 100644 --- a/06-JS-V/homework/homework.js +++ b/06-JS-V/homework/homework.js @@ -8,12 +8,28 @@ function crearUsuario() { // {{nombre}} debe ser el nombre definido en cada instancia // Devuelve la clase // Tu código: + function Usuario(opciones) { + this.usuario = opciones.usuario; + this.nombre = opciones.nombre; + this.email = opciones.email; + this.password = opciones.password; + } + Usuario.prototype.saludar = function () { + return `Hola, mi nombre es ${this.nombre}`; + + } + return Usuario; } function agregarMetodoPrototype(Constructor) { // Agrega un método al Constructor del `prototype` // El método debe llamarse "saludar" y debe devolver la string "Hello World!" // Tu código: + Constructor.prototype.saludar = function(){ + return "Hello World!"; + } + + } function agregarStringInvertida() { @@ -22,6 +38,13 @@ function agregarStringInvertida() { // Ej: 'menem'.reverse() => menem // 'toni'.reverse() => 'inot' // Pista: Necesitarás usar "this" dentro de "reverse" + String.prototype.reverse = function () { + var palabrainvertida =""; + for (var i = this.length; i != 0; i--){ + palabrainvertida += this.charAt(i -1 ); + } + return palabrainvertida; + }; } // ---------------------------------------------------------------------------// @@ -36,8 +59,22 @@ function agregarStringInvertida() { // } class Persona { - constructor(/*Escribir los argumentos que recibe el constructor*/) { + constructor(nombre, apellido,edad, domicilio) { // Crea el constructor: + this.nombre = nombre; + this.apellido = apellido; + this.edad = edad; + this.domicilio = domicilio; + this.detalle = function() { + // crear obdeto desde funcion y rernar + return { + Nombre: this.nombre, + Apellido: this.apellido, + Edad: this.edad, + Domicilio: this.domicilio, + + } + }; } } @@ -46,17 +83,22 @@ function crearInstanciaPersona(nombre, apellido, edad, dir) { //Con esta función vamos a crear una nueva persona a partir de nuestro constructor de persona (creado en el ejercicio anterior) //Recibirá los valores "Juan", "Perez", 22, "Saavedra 123" para sus respectivas propiedades //Devolver la nueva persona creada + const persona = new Persona(nombre, apellido, edad, dir); + return persona; + } function agregarMetodo() { //La función agrega un método "datos" a la clase Persona que toma el nombre y la edad de la persona y devuelve: //Ej: "Juan, 22 años" + Persona.prototype.datos = function(){ + // return this.Nombre +", " + this.edad + "años" + return `${this.nombre}, ${this.edad} años`; + } } - // No modificar nada debajo de esta línea -// -------------------------------- - +// ---------------- module.exports = { crearUsuario, agregarMetodoPrototype,