-
-
Save nishithMobinius/96d8a5a4f01a1ef65a1d9bbbadfbe361 to your computer and use it in GitHub Desktop.
filtering products
This file contains 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
const productsArray =[{ _id:'1' }, { _id:'2' }, { _id:'3' }, { _id:'4' }, { _id:'5' }] | |
const alreadyAddedProducts = [{ _id:'1', status:'completed' }, { _id:'4', status:'inProgress' }, { _id:'5', status:'inProgress' }] | |
const op = productsArray.filter(product=> | |
!alreadyAddedProducts.some(addedProduct=> | |
addedProduct._id===product._id && addedProduct.status==='inProgress' | |
)) | |
console.log(op) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this filters products array based on status and id of already added products
your output would be this [{ _id:'1' }, { _id:'2' }, { _id:'3' }]