Created
November 26, 2020 14:42
-
-
Save DeVoresyah/c5897e2649c815917d8301ec97d06221 to your computer and use it in GitHub Desktop.
Make A Coffee
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 makeACoffee = (buyer, specs) => { | |
const coffees = [] | |
buyer.map(person => { | |
const findSpec = specs.find(opt => person === opt.id) | |
coffees.push({ | |
id: person, | |
coffee: `Cofee with ${findSpec.options}` | |
}) | |
}) | |
} | |
const buyer = ["A", "B", "C", "D"] | |
const specs = [{ | |
id: "A", | |
options: "Black." | |
}, { | |
id: "B", | |
options: "Cream only." | |
}, { | |
id: "C", | |
options: "Sugar and cream." | |
}, { | |
id: "D", | |
options: "Sugar only." | |
}] | |
makeACoffee(buyer, specs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment