Skip to content

Instantly share code, notes, and snippets.

@kevinyc-dri
Last active April 9, 2021 15:52
Show Gist options
  • Save kevinyc-dri/ea4689e7232cf3b20545cdfa9f6080fa to your computer and use it in GitHub Desktop.
Save kevinyc-dri/ea4689e7232cf3b20545cdfa9f6080fa to your computer and use it in GitHub Desktop.
Day 5 of import export
We learned
const allCoffees = require('./data/allCoffees.json')
// console.log('this is my list of coffees', coffees)
exports.getCoffees = (name) => {
allCoffees.forEach((recipe) => {
if (
recipe.ingredients.includes('Milk') ||
recipe.ingredients.includes('Cream') ||
recipe.ingredients.includes('Steamed Milk') ||
recipe.ingredients.includes('1oz Steamed Milk')
) {
console.log(name, 'cant touch this', recipe.id, recipe.title)
}
})
}
// name this function get coffees and export it
exports.getCoffeesTitles = function() {
// filter all coffees which is an array of objects
const coffeeTitles = allCoffees.filter(function(item){
// return each coffee with its title
return item.title
})
// showing new array with just titles
console.log('here is my new array with just titles', coffeeTitles)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment