Skip to content

Instantly share code, notes, and snippets.

@ivandevp
Created March 1, 2017 16:46
Show Gist options
  • Select an option

  • Save ivandevp/445c017e7adf60ba71842b2537f6dbdb to your computer and use it in GitHub Desktop.

Select an option

Save ivandevp/445c017e7adf60ba71842b2537f6dbdb to your computer and use it in GitHub Desktop.
Creación de arreglo de objetos
var numeroEstudiantes = parseInt(prompt("Dame el # de estudiantes"));
var estudiantes = [];
for (var i = 0; i < numeroEstudiantes; i++) {
var nombre = prompt("Ingresa el nombre " + i);
var apellidos = prompt("Ingresa el apellido " + i);
var estudiante = {};
estudiante.nombre = nombre;
estudiante.apellidos = apellidos;
estudiantes.push(estudiante);
}
console.log(estudiantes);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment