Last active
June 28, 2018 17:50
-
-
Save moondef/629572c347ec920ad328304e986a0868 to your computer and use it in GitHub Desktop.
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 addToCart = (cart, pokemon) => { | |
if (inCart(cart, pokemon)) { | |
cart.find(item => item.name === pokemon.name).count += 1; | |
} else { | |
pokemon['count'] = 1 | |
cart.push(pokemon) | |
} | |
return cart | |
} | |
const inCart = (cart, pokemon) => cart.some(item => item['name'] === pokemon.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment