Last active
October 31, 2020 17:28
-
-
Save madiodio/5ae9ea59775a4de8ad2a5e3321a76418 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let A = [ | |
{ _id: "34231555", status: "CANCELED", motif: "unable" }, | |
{ _id: "1234551", status: "FAILLED", motif: "no number" }, | |
, | |
{ _id: "1234455", status: "CANCELED", motif: "injoignable" }, | |
]; | |
let B = ["34231555", "1234455"]; | |
// First, we filter only ids we want to update! | |
let filteredItemIds = A.filter(item => B.includes(item._id)) | |
// Now update status and motifs based , C will the result of the update so the new reference you will need to use instead of A | |
let C = filteredItemIds.map(item => { | |
item.status = "DELETED" | |
item.motif = "Just deleted" | |
return item; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment