Question: In JavaScript please. In this JavaScript object, how would I access 'name', in the variable data? My desired result would be to output the string
In JavaScript please.
In this JavaScript object, how would I access 'name', in the variable data?
My desired result would be to output the string name 'Crab with Butter'.
I have tried to access it using dot notation, for example, data.name but I am getting undefined. The string "0" is what I am unable to get past. I have tried to use toString() method but I am getting undefined also.
let data = { "0":{ "ingredients": [ {"name":"Crab","unit":"Tsp","amount":3}, {"name":"Butter","unit":"Cup","amount":12}, ], "name":"Crab with Butter", "preptime":"13", "cooktime":"78", "id":"0" } };
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
