Created
July 11, 2018 13:58
-
-
Save matheus-rossi/c12de8f9e18ac3d54042c920f1abbed9 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
// Objeto Inicial | |
const refeicaoArray = [ | |
{ id: 1, descricao: 'Café da Manhã', calorias: 420 }, | |
{ id: 2, descricao: 'Almoço', calorias: 580 } | |
] | |
// Removendo item no array refeicoes (.filter) | |
function filtro (refeicao) { | |
if (refeicao.id === 2) { | |
return true | |
} | |
} | |
const refeicaoFiltradas = refeicaoArray.filter(filtro) | |
console.log(refeicaoFiltradas) // [ { id: 2, descricao: 'Almoço', calorias: 580 } ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment