Created
September 9, 2020 22:34
-
-
Save mpaleo/4d70986ba5e7daeaa469d78eb1e77eb5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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