Skip to content

Instantly share code, notes, and snippets.

@shahab65
Last active October 14, 2020 03:55
Show Gist options
  • Save shahab65/c7bb0c9f3685ee4122adda783646d67d to your computer and use it in GitHub Desktop.
Save shahab65/c7bb0c9f3685ee4122adda783646d67d to your computer and use it in GitHub Desktop.

remove from array in returning removed item:

const removeUser = id => {
  const index = users.findIndex((user) => user.id === id)
  
  if (index !== -1) {
    return users.splice(index, 1)[0]
    }
    }

find item with longest length(only one of them)

f.sort((a,b)=>{return b.length - a.length })[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment