I want to write a code with for in and for loop so that :
It will loop through all recipes in the recipeBook, and print the recipe name followed by its ingredients list. For example, the output for the chocolate cake might look as follows:
Chocolate Cake:
- 1 3/4 cup flour
- 1/2 cup cocoa
- 2 tsp baking powder
- 1 cup Chelsea White Sugar
- 125g butter
- 2 Tbsp Chelsea Golden Syrup
- 2 eggs
- 1 1/2 cup milk
- 2 tsp baking soda
- 1 tsp vanilla essence
Code to add "chocolate cake" to the recipe book could look like this:
recipeBook["Chocolate Cake"] = [
"1 3/4 cup flour",
"1/2 cup cocoa",
"2 tsp baking powder",
"1 cup sugar",
"125g butter",
"2 Tbsp golden syrup",
"2 eggs",
"1 1/2 cup milk",
"2 tsp baking soda",
"1 tsp vanilla essence"
];
Prakash nidhi Verma
07-Jun-2018Hi folks, you should make a table like charts which is shown as you wants. than uses loops in/for or nested for type loops for recipeBook.
you can follow this code is shown below..
define all variables correctly and it's another way to solve your problem. you should try this code for loop...
you can explore more in nested loop by this blog,which is given by our another mindstick member.
Link: https://www.mindstick.com/blog/390/using-javascript-nested-loops
glad to help, i hope it will helpful for you.
Happy Coding :)