Last active
August 6, 2021 21:53
-
-
Save ggteixeira/59d01a344aa920f160d630d110a21f74 to your computer and use it in GitHub Desktop.
filterBy() function
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
// Criar um filtro por chave e valor sem usar a função filter | |
function filterBy(key, value, array) { | |
const filteredList = []; | |
array.map((carro) => { | |
if (!!key || !!value) { | |
if (carro[key] == value) { | |
filteredList.push(carro); | |
} | |
} | |
}); | |
return filteredList; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment