Please help me to solve the task below.
I want to display an object value, which property is equal to the variable txt. If txt = "my location"
, I want to display the value of “my location”.
And also I want to display it in such way:
city: value1,
street: value2
var obj = {“my name”: “first second”, “my location”: {“city”: “value1”, “street”: “value2”}};
objkeys = Object.keys(obj);
for (var i = 0; i < objkeys.length; ++i) console.log(objkeys[i]);
var txt = “my location”;
if (txt === objkeys[i]) console.log(???)
What should be written instesd of ???
Thanks!