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

Se agrega la ultima actualizacion #6

Open
wants to merge 3 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
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// Use IntelliSense para saber los atributos posibles.
// Mantenga el puntero para ver las descripciones de los existentes atributos.
// Para más información, visite: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\01.js"
}
]
}
16 changes: 16 additions & 0 deletions 01.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,25 @@ function soloNumeros(array) {
// soloNumeros([1, 'Henry', 2]) debe retornar [1, 2]

// Tu código aca:
const element = [];
for (let index = 0; index < array.length; index++) {

if (typeof array[index] !== "string") {
element.push(array[index] )

}



}

return element;


}



// No modifiques nada debajo de esta linea //


Expand Down
20 changes: 19 additions & 1 deletion 02.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,27 @@ function stringMasLarga(strings) {
// stringMasLarga(['hi', 'hello', 'ni hao', 'guten tag']); debe retornar 'guten tag'
// stringMasLarga(['JavaScript', 'HTML', 'CSS']); debe retornar 'JavaScript'

// Tu código aca
// Tu código aca
let contador = 0 ;
var string = "" ;
for (let index = 0; index < strings.length; index++)

{


if (contador <= strings[index].length)
{
contador = strings[index].length ;
string = strings[index]

}


}
return string ;
}


// No modifiques nada debajo de esta linea //

module.exports = stringMasLarga
10 changes: 9 additions & 1 deletion 03.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@ function buscarAmigo(amigos, nombre) {
// buscarAmigo(amigos, 'toni') debe devolver { nombre: 'toni', edad: 33 };

// Tu código aca:


for (var i = 0; i < amigos.length; i++) {

if (amigos[i].nombre == nombre) {

return amigos [i];
}
}
}


// No modifiques nada debajo de esta linea //

Expand Down
23 changes: 23 additions & 0 deletions 04.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,31 @@ function numeroSimetrico(num) {
// numeroSimetrico(11711) devuelve true

// Tu código:
residuo = 0 ;
numero = num ;

while (num > 0) {
digito = num % 10 ;
residuo = ((residuo *10) +digito ) ;
num = Math.round (num / 10 ) ;




}

if (residuo == numero )

{
return true ;
}
return false ;

}
numeroSimetrico(2341) ;




// No modifiques nada debajo de esta linea //

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

// Tu código acá:

arreglo = [ ];

}

for ( var i = 0; i < array.length; i++)

{

arreglo.push ( array[i][propiedad]);

}


return arreglo ;

}
var productos = [{ name: 'TV LCD', price: 100}, { name: 'Computadora', price: 500 }]
pluck(productos, 'name')
// No modifiques nada debajo de esta linea //

module.exports = pluck
23 changes: 22 additions & 1 deletion 06-07-08.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ function crearClasePersona() {
// El constructor de la clase Persona recibe nombre (string), edad (integer), hobbies (array de strings), amigos (array de objetos)
// 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;


}

Expand All @@ -20,6 +27,11 @@ function crearClasePersona() {
// No debe retornar nada.

// Tu código aca:




this.amigos.push({ nombre: nombre, edad: edad });

}

Expand All @@ -29,6 +41,8 @@ function crearClasePersona() {

// 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,6 +52,8 @@ function crearClasePersona() {
// persona.getFriends() debería devolver ['martin', 'toni']

// Tu código aca:

return this.amigos.map(amigo => amigo.nombre);

}

Expand All @@ -47,6 +63,7 @@ function crearClasePersona() {
// persona.getHobbies() debe devolver ['correr', 'dormir', 'nadar']

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

}

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

// Tu código aca:

let sumaEdad = 0;
this.amigos.forEach(amigo => {sumaEdad += amigo.edad;});
return sumaEdad / this.amigos.length;

}
};

return Persona;
}

crearClasePersona () ;
// No modifiques nada debajo de esta linea //

module.exports = crearClasePersona
11 changes: 11 additions & 0 deletions 09.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ function filtrar(funcion) {
// productos.filtrar(function(p) {
// return p.price >= 50;
// }) => [{price: 100, name:'tv'}]

Array.prototype.filtrar = function(funcion) {
var resultado = [];
for (var i = 0; i < this.length; i++) {
if (funcion(this[i])) {
resultado.push(this[i]);
}
}
return resultado;
};


};

Expand Down