0

I need a function that filter some items from array ,like below:

how to make it? Thank you so much in advance !

const users = [
   {id:"1",name:"Jane"},
   {id:"2",name:"Lucy"},
   {id:"3",name:"Li Li"},
   {id:"4",name:"Hilton"},
   {id:"5",name:"Rose"},
   {id:"6",name:"Ha Ha"},
]

//user with this id need to been remove.
const filteredUsers = [
   '1','2','5'
]

function filterUsers(allUsers,filteredUsers){
   //return after filtered list
}
2
  • 1
    you can use users.filter(user => filteredUsers.includes(user.id)) Commented May 17, 2022 at 10:56
  • Well done my friend!Thank you so much !!! Commented May 17, 2022 at 11:01

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.