Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created June 11, 2020 02:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/788341896f04c7b3490aa111c1b5b30e to your computer and use it in GitHub Desktop.
Save parzibyte/788341896f04c7b3490aa111c1b5b30e to your computer and use it in GitHub Desktop.
const indiceDeProducto = (carrito, idProducto) => {
return carrito.findIndex(productoDentroDelCarrito => productoDentroDelCarrito.id === idProducto);
}
const existeProducto = (carrito, producto) => {
return indiceDeProducto(carrito, producto.id) !== -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment