Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created July 29, 2019 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/e9780db0e2493735a09ae8387f26a6eb to your computer and use it in GitHub Desktop.
Save parzibyte/e9780db0e2493735a09ae8387f26a6eb to your computer and use it in GitHub Desktop.
let arreglo = [{
nombre: "Maggie",
tipo: "Perro",
edad: 3,
}, {
nombre: "Guayaba",
tipo: "Perro",
edad: 1,
}, {
nombre: "Snowball",
tipo: "Gato",
edad: 1,
},
];
let busqueda = "Guayaba";
console.log("Tenemos el arreglo: ", arreglo);
console.log("Buscando en donde el nombre sea igual a: ", busqueda);
let indice = arreglo.findIndex(mascota => mascota.nombre === busqueda);
console.log("El elemento buscado está en el índice ", indice);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment