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

ejercicios resueltos #14

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
ejercicios resueltos
Alexcarp-ar committed Feb 28, 2023
commit a1f4bdb673edb5050ab11c57d94a38c8d784662d
23 changes: 22 additions & 1 deletion M07 JavaScript Clases/Ejercicio 01.js
Original file line number Diff line number Diff line change
@@ -10,18 +10,39 @@ function crearUsuario() {
// El valor {{nombre}} debe ser el nombre definido para la instancia de la clase.
// Retornar la clase.
// Tu código:
}

class Usuario {
constructor(usuario, nombre, email, password) {
this.usuario = usuario;
this.nombre = nombre;
this.email = email;
this.password = password;
}
saludar(){
return 'Hola, mi nombre es ' + this.nombre;
}
}
return Usuario;
}


function agregarMetodoPrototype(Usuario) {
// Agrega un método al prototipo de "Usuario".
// El método debe llamarse "saludar" y debe devolver el string "Hello World!".
// Tu código:
Usuario.prototype.saludar = function () {
return "Hello World!";
}

}

function agregarStringInvertida() {
// Agrega un método al prototipo de "String" que devuelva la misma cadena de caracteres, pero invertida.
// El método debe llamarse "reverse".
// [PISTA]: necesitarás utilizar el objeto "this".
String.prototype.reverse = function() {
return this.split("").reverse().join('');
}
}

/*⚠️ NO MODIFIQUES NADA DEBAJO DE ESTO ⚠️*/
33 changes: 28 additions & 5 deletions M07 JavaScript Clases/Ejercicio 02.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,48 @@
/*⚠️ NO MODIFIQUES EL NOMBRE DE LAS DECLARACIONES ⚠️*/
/*2️⃣ EJERCICIO 02 2️⃣*/

class Persona {
// Crea el constructor de la clase "Persona".
// Debe tener las propiedades: "nombre", "apellido", "edad" y "domicilio".
// Debe tener un método llamado "detalle" que nos devuelva un objeto con las propiedades de la persona y
// sus valores.
// Crea el constructor de la clase "Persona".
// Debe tener las propiedades: "nombre", "apellido", "edad" y "domicilio".
// Debe tener un método llamado "detalle" que nos devuelva un objeto con las propiedades de la persona y
// sus valores.
class Persona {
constructor(nombre, apellido, edad, domicilio){
this.nombre = nombre;
this.apellido = apellido;
this.edad = edad;
this.domicilio = domicilio;

this.detalle = function() {
return {
nombre: nombre,
apellido: apellido,
edad: edad,
domicilio: domicilio
}
}
}
}

function crearInstanciaPersona(nombre, apellido, edad, domicilio) {
// En este ejercicio debes crear una instancia de la clase construida en el ejercicio anterior.
// Recibirás las propiedades por parámetro.
// Retornar la instancia creada.
// Tu código:
let instancia = new Persona(nombre, apellido, edad, domicilio)
return instancia;
}

function agregarMetodo() {
// La función agrega un método "datos" a la clase "Persona".
// Este método toma la propiedad "nombre" y "edad", y devuelve el string:
// Ejemplo: "Juan, 22 años".
// Tu código:
Persona.prototype.datos = function() {
return `${this.nombre}, ${this.edad} años`;


}

}

/*⚠️ NO MODIFIQUES NADA DEBAJO DE ESTO ⚠️*/