Skip to content

Instantly share code, notes, and snippets.

@hebertcisco
Created May 23, 2020 05:33
Show Gist options
  • Save hebertcisco/e7dceecf369355171126473596baacd7 to your computer and use it in GitHub Desktop.
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.
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