Skip to content

Instantly share code, notes, and snippets.

@robertguturing
Created July 16, 2020 21:55
Show Gist options
  • Save robertguturing/4e19fba9d31e5d2a26ff2fbe258a78f7 to your computer and use it in GitHub Desktop.
Save robertguturing/4e19fba9d31e5d2a26ff2fbe258a78f7 to your computer and use it in GitHub Desktop.

Coffee Fun

You are creating a coffee app that lists certain info about this set of coffee data

let coffees = [
  { roaster: "Sweet Bloom", flavorProfile: ["cocoa nibs", "praline", "blackberry"] cost: 14},
  { roaster: "Unravel Coffee", flavorProfile: ["dried peaches", "apricot", "tangerine cream"], cost: 15 },
  { roaster: "Middle State", flavorProfile: ["blackberry", "chocolate", "jackfruit"], cost: 16 },
  { roaster: "Copper Door", flavorProfile: ["blackberry", "honey", "blacktea"], cost: 15 },
  { roaster: "Jubilee", flavorProfile: ["honeysuckle", "vanilla", "grapefruit"], cost: 15 }
]

Level 1

Write a function that returns me an array of all the roasters that have "blackberry" in the flavor profile. So `["Sweet Bloom", "Middle State", "Copper Door"]

Level 2

Refactor your function to get me the total cost of all the coffee that has "blackberry" as part of the flavor profile. The value returned should be 45

Level 3

Refactor your function to return me a list of all the flavor profiles that have "blackberry".
The value returned should be ["cocoa nibs", "praline", "blackberry", "blackberry", "chocolate", "jackfruit", "blackberry", "honey", "blacktea"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment