This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
@@ -48,7 +48,7 @@
|
||||
];
|
||||
const cocktailRecipes = [honoluluFlip, casualFriday, pinkDolly];
|
||||
|
||||
const ingredientsFromMyBar = [
|
||||
const AVAILABLE_INGREDIENTS = [
|
||||
'Pineapple',
|
||||
'Maracuja Juice',
|
||||
'Cream',
|
||||
@@ -65,19 +65,26 @@
|
||||
];
|
||||
|
||||
const isMixableWithMyIngredients = (cocktailRecipe) => {
|
||||
/* ??? */
|
||||
return isMixableWith(cocktailRecipe, AVAILABLE_INGREDIENTS);
|
||||
};
|
||||
|
||||
const isMixableWith = (cocktailRecipe, availableIngredients) => {
|
||||
return cocktailRecipe.every((ingredientFromRecipe) =>
|
||||
hasIngredient(availableIngredients, ingredientFromRecipe)
|
||||
hasIngredient(availableIngredients, ingredientFromRecipe),
|
||||
);
|
||||
};
|
||||
|
||||
const hasIngredient = (listOfIngredients, searchedIngredient) => listOfIngredients.includes(searchedIngredient);
|
||||
|
||||
// console.log(cocktailRecipes./* ??? */(isMixableWithMyIngredients));
|
||||
const hasIngredient = (listAr, searchStr) => {
|
||||
return listAr.includes(searchStr);
|
||||
};
|
||||
console.log(cocktailRecipes);
|
||||
console.log('isMixable: ', isMixableWith(casualFriday, AVAILABLE_INGREDIENTS));
|
||||
|
||||
console.log(
|
||||
cocktailRecipes.find((recipeAr) => {
|
||||
return isMixableWithMyIngredients(recipeAr);
|
||||
}),
|
||||
);
|
||||
// => [ 'Vodka', 'Lime Juice', 'Apple Juice', 'Cucumber' ]
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user