Skip to content

Instantly share code, notes, and snippets.

@Sarav-S
Created July 19, 2020 09:20
Show Gist options
  • Save Sarav-S/f51fd50d10928b3cc345eae290429ac6 to your computer and use it in GitHub Desktop.
Save Sarav-S/f51fd50d10928b3cc345eae290429ac6 to your computer and use it in GitHub Desktop.
const cart = {
items: [
{ name: 'Item 1', value: 200, in_stock: true },
{ name: 'Item 2', value: 100, in_stock: false },
{ name: 'Item 3', value: 200, in_stock: true },
]
}
// Using traditional javascript
const inStock = items => items.filter(item => item.in_stock);
const inStockItems = inStock(cart.items);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment