Skip to content

Instantly share code, notes, and snippets.

@mpaleo
Created September 9, 2020 22:34
Show Gist options
  • Save mpaleo/4d70986ba5e7daeaa469d78eb1e77eb5 to your computer and use it in GitHub Desktop.
Save mpaleo/4d70986ba5e7daeaa469d78eb1e77eb5 to your computer and use it in GitHub Desktop.
const inmuebles = [
{
id: 1,
...
},
{
id: 2,
...
},
{
id: 3,
...
},
{
id: 2,
...
}
]
let inmuebleAMostrar
inmuebleAMostrar = inmuebles.find(function (inmueble) {
return inmueble.id === 2
})
inmuebleAMostrar = inmuebles.filter(function (inmueble) {
return inmueble.id === 2
})[0]
for (let index = 0; index < inmuebles.length; index++) {
if (inmuebles[index].id === 2) {
inmuebleAMostrar = inmuebles[index]
break
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment