Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

el primero #51

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 67 additions & 24 deletions 02-JS-I/homework/homework.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -74,118 +74,154 @@ 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) {
// Devuelve "true" si "num" es par
// 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;

}

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) {
//La función va a recibir un entero. Devuelve como resultado una cadena de texto que indica si el número es positivo o negativo.
//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;

}

Expand All @@ -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;
}


Expand All @@ -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";

}


Expand Down
50 changes: 46 additions & 4 deletions 06-JS-V/homework/homework.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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;
};
}

// ---------------------------------------------------------------------------//
Expand All @@ -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,

}
};

}
}
Expand All @@ -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,
Expand Down