Skip to content
6 changes: 5 additions & 1 deletion 01.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ function soloNumeros(array) {
// soloNumeros([1, 'Henry', 2]) debe retornar [1, 2]

// Tu código aca:

var array;
var numero;
let filtrados = array.filter(numero => Number.isInteger(numero));
return filtrados

}

// No modifiques nada debajo de esta linea //
Expand Down
14 changes: 14 additions & 0 deletions 02.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ function stringMasLarga(strings) {
// stringMasLarga(['JavaScript', 'HTML', 'CSS']); debe retornar 'JavaScript'

// Tu código aca

var maslarga="";
var strings

for (let i = 0; i<strings.length; i++){

if (strings[i].length>maslarga.length) {
maslarga=strings[i]

}
}

return maslarga

}

// No modifiques nada debajo de esta linea //
Expand Down
11 changes: 10 additions & 1 deletion 03.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ function buscarAmigo(amigos, nombre) {
// buscarAmigo(amigos, 'toni') debe devolver { nombre: 'toni', edad: 33 };

// Tu código aca:

var i = 0;
while (i < amigos.length && amigos[i].nombre != nombre) {
i++;
}
if (i < amigos.length) {
return amigos[i];
}
else {
return null;
}
}

// No modifiques nada debajo de esta linea //
Expand Down
5 changes: 5 additions & 0 deletions 04.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ function numeroSimetrico(num) {
// numeroSimetrico(11711) devuelve true

// Tu código:
var num
return ""+num === (""+num).split("").reverse().join("")




}

Expand Down
5 changes: 5 additions & 0 deletions 05.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ function pluck(array, propiedad) {
// Pista: es una buena oportunidad para usar map.

// Tu código acá:
var a
let pedidoarray = array.map(function(a){
return a[propiedad]
});
return pedidoarray;

}

Expand Down
32 changes: 24 additions & 8 deletions 06-07-08.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@ function crearClasePersona() {
// Inicializar las propiedades de la persona con los valores recibidos como argumento

// Tu código aca:

this.nombre = nombre,
this.edad = edad,
this.hobbies = hobbies,
this.amigos = amigos,
this.persona = function(){
return{
nombre: this.nombre,
edad: this.edad,
hobbies: this.hobbies,
amigos: this.amigos,
}
}
}

addFriend(nombre, edad) {
Expand All @@ -20,15 +31,16 @@ function crearClasePersona() {
// No debe retornar nada.

// Tu código aca:

let amigo = {nombre, edad}
this.amigos.push(amigo);
}

addHobby(hobby) {
// El método 'addHobby' recibe un string 'hobby' y debe agregarlo al arreglo de hobbies de la persona.
// No debe retornar nada.

// Tu código aca:

this.hobbies.push(hobby);
}
getFriends() {
// El método 'getFriends' debe retornar un arreglo con sólo los nombres del arreglo de amigos
Expand All @@ -38,15 +50,20 @@ function crearClasePersona() {
// persona.getFriends() debería devolver ['martin', 'toni']

// Tu código aca:

const transformarObjetoAmigoANombre = ((amigo) => amigo.nombre);
const indexed = this.amigos.map(transformarObjetoAmigoANombre);
return indexed
}



getHobbies() {
// El método 'getHobbies' debe retornar un arreglo con los hobbies de la persona
// Ej:
// persona.getHobbies() debe devolver ['correr', 'dormir', 'nadar']

// Tu código aca:
return this.hobbies

}

Expand All @@ -66,10 +83,9 @@ function crearClasePersona() {
// persona.getPromedioEdad() debería devolver 29 ya que (33 + 25) / 2 = 29

// Tu código aca:

}
};

return this.amigos.map(amigo => amigo.edad).reduce((a, b) => a + b) / this.amigos.length
}
}
return Persona;
}

Expand Down
35 changes: 35 additions & 0 deletions 09.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,41 @@
No comentar la funcion
*/
function filtrar(funcion) {
var productos = [{
price: 100,
name: 'tv'
}, {
price: 50,
name: 'phone'
}, {
price: 30,
name: 'lamp'
}];

// Definir el método antes de ejecutar
Array.prototype.filtrar = function(cb) {
// Crear el arreglo que se va a devolver
let newArray = [];
// Recorrer elementos actuales
this.forEach(item => {
// Analizar el resultado de la función de retorno o "callback"
if(cb(item)) {
// Si devuelve verdadero, agregar elemento
newArray.push(item);
}
});
// Devolver arreglo filtrado
return newArray;
};

// Ejecutar método de filtro proporcionando función de retorno o "callback"
let filtrado = productos.filtrar(function(p) {
// Incluir solo productos que cumplen esta condición
return p.price >= 50;
});

// Mostrar resultado
console.log(filtrado);
// Escribi una función filtrar en el prototipo de Arrays,
// que recibe una funcion (callback) que devuelve true o false.
// filtrar los elementos de ese arreglo en base al resultado de esa funcion
Expand Down
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,89 @@ Te compartimos un poco de documentación para facilitarte algunas respuestas. ¡
<br />

## **💪¡MUCHA SUERTE!👊**
<!-- // var deportes ={
// conBalon:['Football','Basquetball','Rugby'],
// sinBalon:['Boxeo','Surf','Trekking'],
// };

// var persona = { nombre: 'Lucas', edad: 26, estudios: { esProgramador: true } };
// console.log(persona)
// console.log(persona.edad)

// ACCEDER
// var persona = { nombre: 'Lucas', edad: 26, estudios: { esProgramador: true } };
// console.log(persona.edad)
// persona.nombre='Martin';
// console.log(persona.nombre)
// console.log(persona.estudios.esProgramador)
// persona.edad=25
// console.log(persona.edad)
// console.log(persona)

// var autos={};
// autos.marcas=['Ford','Audi','VW'];
// autos.años=['1','2','3'];
// console.log(autos);
// delete autos.marcas;
// console.log(autos)

// var misFunciones={
// saludar: function(){
// console.log("hola Quelvin");
// }
// }
// misFunciones.saludar();
// // DOT NOTATION
// var atuendos = { manos: ['Guantes', 'Anillos'], pies: ['Zapatos', 'Soquetes'] };
// // console.log(atuendos.manos)
// atuendos["piernas"]=['Bermudas','Pantalones']
// console.log(atuendos)
var comidas={}
var diferenciaDeNotaciones= function(propUno,propDos){
comidas[propUno]=['Frutas', 'Vegetales']
comidas[propDos]= ['Hamburguesas', 'Papas Fritas'];
};
diferenciaDeNotaciones('saludable','noSaludable');
console.log(comidas); -->
<!-- ar agenda = {nombre: ['Kalia', 'Quelvin'], segundonombre: 'Yanira', año: 1994, celular: '940434519' };
console.log(agenda)
var tienePropiedad1 = agenda.hasOwnProperty('nombre');
console.log("tiene la propiedad nombre: "+ tienePropiedad1);
var tienePropiedad2 = agenda.hasOwnProperty('segundonombre');
console.log("tiene la propiedad segundonombre: "+ tienePropiedad2);
var tienePropiedad3 = agenda.hasOwnProperty('año');
console.log("tiene la propiedad año: "+ tienePropiedad3);
var tienePropiedad4 = agenda.hasOwnProperty('celular');
console.log("tiene la propiedad celular: "+ tienePropiedad4);

// KEYS
// var agenda = { autor: 'Borges', genero: 'Policial', año: 1990 };
var todasLasPropiedades = Object.keys(agenda);
console.log(todasLasPropiedades)


// console.log(todasLasPropiedades);
for (let x in agenda) {
// console.log(x);
console.log(agenda[x]);
// console.log(agenda[x]);
}

//agenda.año=1
agenda['profesion']='Administrador'
console.log(agenda)
console.log(agenda.nombre[0])




// //THIS
// var mascota = {
// animal: 'Perro',
// raza: 'Ovejero Alemán',
// amistoso: true,
// dueño: 'María López',
// info: () => {
// console.log('Mi perro es un ' + this.raza);
// },
// }; -->