Skip to content

Instantly share code, notes, and snippets.

@nickgrato
Created January 16, 2022 16:54
Show Gist options
  • Save nickgrato/6c6ad40c96d15cb048a319307c99fb81 to your computer and use it in GitHub Desktop.
Save nickgrato/6c6ad40c96d15cb048a319307c99fb81 to your computer and use it in GitHub Desktop.
const filterByColor = color => {
this.products.filter( product => {
let colorFound
// [0] index in this case is the 'color' options
const colors = product.options[0].values 
if(colors.indexOf(color) != -1) colorFound = true
return colorFound
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment