Created
July 2, 2020 21:13
-
-
Save andreiskandar/6fd07b9fdf2d2be17095c2b4abae7915 to your computer and use it in GitHub Desktop.
Kata 10 - The Great Codeville Bake-off
This file contains hidden or 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 chooseRecipe = function(bakeryA, bakeryB, recipes) { | |
| for(const recipe of recipes){ | |
| const hasItemA = (bakeryA.includes(recipe.ingredients[0]) || bakeryB.includes(recipe.ingredients[0])); | |
| const hasItemB = (bakeryA.includes(recipe.ingredients[1]) || bakeryB.includes(recipe.ingredients[1])); | |
| if(hasItemA && hasItemB) | |
| return recipe.name; | |
| } | |
| } | |
| // let bakeryA = ['saffron', 'eggs', 'tomato paste', 'coconut', 'custard']; | |
| // let bakeryB = ['milk', 'butter', 'cream cheese']; | |
| // let recipes = [ | |
| // { | |
| // name: 'Coconut Sponge Cake', | |
| // ingredients: ['coconut', 'cake base'] | |
| // }, | |
| // { | |
| // name: 'Persian Cheesecake', | |
| // ingredients: ['saffron', 'cream cheese'] | |
| // }, | |
| // { | |
| // name: 'Custard Surprise', | |
| // ingredients: ['custard', 'ground beef'] | |
| // } | |
| // ]; | |
| // console.log(chooseRecipe(bakeryA, bakeryB, recipes)); | |
| bakeryA = ['potatoes', 'bay leaf', 'raisins']; | |
| bakeryB = ['red bean', 'dijon mustard', 'apples']; | |
| recipes = [ | |
| { | |
| name: 'Potato Ganache', | |
| ingredients: ['potatoes', 'chocolate'] | |
| }, | |
| { | |
| name: 'Sweet Fish', | |
| ingredients: ['anchovies', 'honey'] | |
| }, | |
| { | |
| name: "Nima's Famous Dijon Raisins", | |
| ingredients: ['dijon mustard', 'raisins'] | |
| } | |
| ]; | |
| console.log(chooseRecipe(bakeryA, bakeryB, recipes)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment