var result= {
"drinks": [{
"idDrink": "12734",
"strDrink": "Chocolate Drink",
"strVideo": null,
"strCategory": "Cocoa",
"strIBA": null,
"strAlcoholic": "Non alcoholic",
"strGlass": "Coffee mug",
"strInstructions": "Melt the bar in a small amount of boiling water. Add milk. Cook over low heat, whipping gently (with a whisk, i would assume) until heated well. Don't let it boil! Serve in coffee mug.",
"strDrinkThumb": "https:\/\/www.thecocktaildb.com\/images\/media\/drink\/q7w4xu1487603180.jpg",
"strIngredient1": "Chocolate",
"strIngredient2": "Milk",
"strIngredient3": "Water",
"strIngredient4": "",
"strIngredient5": "",
"strIngredient6": "",
"strIngredient7": "",
"strIngredient8": "",
"strIngredient9": "",
"strIngredient10": "",
"strIngredient11": "",
"strIngredient12": "",
"strIngredient13": "",
"strIngredient14": "",
"strIngredient15": "",
"strMeasure1": "125 gr",
"strMeasure2": "3\/4 L ",
"strMeasure3": "",
"strMeasure4": "",
"strMeasure5": "",
"strMeasure6": "",
"strMeasure7": "",
"strMeasure8": "",
"strMeasure9": "",
"strMeasure10": "",
"strMeasure11": "",
"strMeasure12": "",
"strMeasure13": "",
"strMeasure14": "",
"strMeasure15": "",
"dateModified": "2017-02-20 15:06:20"
}, {
"idDrink": "12736",
"strDrink": "Drinking Chocolate",
"strVideo": null,
"strCategory": "Cocoa",
"strIBA": null,
"strAlcoholic": "Non alcoholic",
"strGlass": "Coffee mug",
"strInstructions": "Heat the cream and milk with the cinnamon and vanilla bean very slowly for 15-20 minutes. (If you don't have any beans add 1-2 tsp of vanilla after heating). Remove the bean and cinnamon. Add the chocolate. Mix until fully melted. Serve topped with some very dense fresh whipped cream. Serves 1-2 depending upon how much of a glutton you are. For a richer chocolate, use 4 oz of milk, 4 oz of cream, 4 oz of chocolate. Serve in coffee mug.",
"strDrinkThumb": "https:\/\/www.thecocktaildb.com\/images\/media\/drink\/u6jrdf1487603173.jpg",
"strIngredient1": "Heavy cream",
"strIngredient2": "Milk",
"strIngredient3": "Cinnamon",
"strIngredient4": "Vanilla",
"strIngredient5": "Chocolate",
"strIngredient6": "Whipped cream",
"strIngredient7": "",
"strIngredient8": "",
"strIngredient9": "",
"strIngredient10": "",
"strIngredient11": "",
"strIngredient12": "",
"strIngredient13": "",
"strIngredient14": "",
"strIngredient15": "",
"strMeasure1": "2 oz ",
"strMeasure2": "6-8 oz ",
"strMeasure3": "1 stick ",
"strMeasure4": "1 ",
"strMeasure5": "2 oz finely chopped dark ",
"strMeasure6": "Fresh ",
"strMeasure7": " ",
"strMeasure8": " ",
"strMeasure9": " ",
"strMeasure10": " ",
"strMeasure11": " ",
"strMeasure12": "",
"strMeasure13": "",
"strMeasure14": "",
"strMeasure15": "",
"dateModified": "2017-02-20 15:06:13"
}, {
"idDrink": "12690",
"strDrink": "Lassi - A South Indian Drink",
"strVideo": null,
"strCategory": "Other\/Unknown",
"strIBA": null,
"strAlcoholic": "Non alcoholic",
"strGlass": "Highball Glass",
"strInstructions": "Blend in a blender for 3 seconds. Lassi is one of the easiest things to make, and there are many ways of making it. Basically, it is buttermilk (yoghurt whisked with water), and you can choose almost any consistency that you like, from the thinnest to the thickest. Serve cold.",
"strDrinkThumb": "https:\/\/www.thecocktaildb.com\/images\/media\/drink\/iq6scx1487603980.jpg",
"strIngredient1": "Yoghurt",
"strIngredient2": "Water",
"strIngredient3": "Cumin seed",
"strIngredient4": "Salt",
"strIngredient5": "Mint",
"strIngredient6": "",
"strIngredient7": "",
"strIngredient8": "",
"strIngredient9": "",
"strIngredient10": "",
"strIngredient11": "",
"strIngredient12": "",
"strIngredient13": "",
"strIngredient14": "",
"strIngredient15": "",
"strMeasure1": "1\/2 cup plain ",
"strMeasure2": "1 1\/4 cup cold ",
"strMeasure3": "1\/2 tsp ground roasted ",
"strMeasure4": "1\/4 tsp ",
"strMeasure5": "1\/4 tsp dried ",
"strMeasure6": " ",
"strMeasure7": " ",
"strMeasure8": " ",
"strMeasure9": " ",
"strMeasure10": " ",
"strMeasure11": "",
"strMeasure12": "",
"strMeasure13": "",
"strMeasure14": "",
"strMeasure15": "",
"dateModified": "2017-02-20 15:19:40"
}]
};
result.drinks.forEach(function(ingredients){
var ing = Object.keys(ingredients).reduce(function(a, ele) {
if (ele.startsWith('strIngredient') && ingredients[ele].trim() != '') {
if (!a[ingredients.strDrink]) a[ingredients.strDrink] = [];
a[ingredients.strDrink].push(ingredients[ele]);
}
return a;
}, {});
console.log(Object.keys(ing)[0] + ': ' + ing[Object.keys(ing)[0]].join(', '));
})