Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose you are given the following object that describes a recipe. { idMeal: 52780, strMeal: Potato Gratin with Chicken, strIngredient1: Potatoes, strIngredient2: Onions, strIngredient3: Olive

Suppose you are given the following object that describes a recipe.

{ idMeal: "52780", strMeal: "Potato Gratin with Chicken", strIngredient1: "Potatoes", strIngredient2: "Onions", strIngredient3: "Olive Oil", strIngredient4: "Chicken Stock", strIngredient5: null, strIngredient6: "", strIngredient7: "Chicken Breasts", strIngredient8: "", strIngredient9: "Spinach", strIngredient10: null, strIngredient11: "", strIngredient12: "", strIngredient13: "", strIngredient14: "Bacon", strIngredient15: "", strIngredient16: null, strIngredient17: "Parmesan", strIngredient18: "Peas", strIngredient19: null, strIngredient20: "Creme Fraiche", dateModified: null, price: 13.99 }

Write a general purpose Javascript function that accepts an object (say recipe) and prints the ingredients to the console, with each ingredient separated by a whitespace. You can write it as a script and then run it on your browser

Keep in mind, we dont want to print the null or empty ingredients. Also, your function should be flexible enough to handle ANY object in the above format i.e. if I test your code by passing in an recipe object that has just 5 valid ingredients and the rest are null or empty, it should still work.

You can assume all recipe objects will have 20 fields for ingredients, but not all of them will be populated.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Science Project Ideas In Health Care Volume 1

Authors: Zemelak Goraga

1st Edition

B0CPX2RWPF, 979-8223791072

More Books

Students also viewed these Databases questions

Question

Explain the basic steps in the communication process.

Answered: 1 week ago

Question

Does it avoid using personal pronouns (such as I and me)?

Answered: 1 week ago

Question

Does it clearly identify what you have done and accomplished?

Answered: 1 week ago