Skip to content

Instantly share code, notes, and snippets.

@ancyrweb
Created January 14, 2022 05:39
Show Gist options
  • Save ancyrweb/9e613b6bf180068e6ddb2b74244abd7e to your computer and use it in GitHub Desktop.
Save ancyrweb/9e613b6bf180068e6ddb2b74244abd7e to your computer and use it in GitHub Desktop.
const users = [
{
id: 1,
username: "supercoder",
},
{
id: 2,
username: "xXxSniperElitexXx",
},
{
id: 3,
username: "sPoNgEbOb_cAsE",
}
];
const withId = (id) => (user) => user.id === id;
const userWithId = users.findIndex(withId(1)); // 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment