Cocktail Recipe Generator
Suggested Cocktail Recipe:
Ingredients: ${getIngredients(cocktail).join(", ")}
Instructions: ${cocktail.strInstructions}
Error fetching cocktail data. Please try again later.
'; } } // Function to extract ingredients from the cocktail object function getIngredients(cocktail) { const ingredients = []; for (let i = 1; i <= 15; i++) { if (cocktail[`strIngredient${i}`]) { ingredients.push(cocktail[`strIngredient${i}`]); } } return ingredients; } // Add event listener to the "Generate Recipe" button document.getElementById('generateRecipe').addEventListener('click', generateCocktailRecipe);