Created
June 19, 2018 01:13
-
-
Save furenku/5d9e5f2d258196bb3d81e40703099908 to your computer and use it in GitHub Desktop.
array filtering inside array
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
personas = [ | |
{ | |
nombre: "juan", | |
materias: [ | |
{ | |
id: "GEO001", | |
name: "geografia 1" | |
}, | |
{ | |
id: "BIO001", | |
name: "biologia 1" | |
}, | |
] | |
}, | |
{ | |
nombre: "marta", | |
materias: [ | |
{ | |
id: "GEO002", | |
name: "geografia 2" | |
}, | |
{ | |
id: "BIO002", | |
name: "biologia 2" | |
}, | |
] | |
}, | |
] | |
resultado = personas.filter(i=>{ | |
return i.materias.map(j=>j.id=="BIO001").includes(true) | |
}) | |
console.log( resultado ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment