Created
May 23, 2020 05:33
-
-
Save hebertcisco/e7dceecf369355171126473596baacd7 to your computer and use it in GitHub Desktop.
The find() method returns the value of the first element of the array that satisfies the provided test function. Otherwise, undefined is returned.
This file contains 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 userISPRO = [ | |
{ | |
nome: "John", | |
pro: true, | |
}, | |
{ | |
nome: "Hima", | |
pro: false, | |
}, | |
{ | |
nome: "Ricardo", | |
pro: false, | |
}, | |
{ | |
nome: "Mariana", | |
pro: true, | |
}, | |
]; | |
const isPro = (item) => item.pro; | |
const user = userISPRO.find(isPro); | |
console.log(user); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment