Created
November 1, 2021 14:07
-
-
Save Stefanacef/778d14b787d3dc028e3bffa29fb3eeb4 to your computer and use it in GitHub Desktop.
How to filter an array and an array of objects | how to filter two arrays
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 arr=['one','two','three','four'] | |
const verif=[ | |
{id:'one'}, | |
{id:'aaaa'}, | |
{id:'two'}, | |
{id:'bbbb'}, | |
{id:'three'}, | |
{id:'four'}, | |
] | |
verif.filter((el)=>{ | |
arr.indexOf(el.id)!=-1 ? console.log(el.id) : null | |
}) | |
// one two three four |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment