0
Javascript Problem
/*Write a function that takes an object with two properties as argument. It should return the value of the property with key country. */ function myFunction(obj){ return //Your code goes here } What's the solution?
6 Answers
+ 3
Ohhh, i see. Well, if you are trying to get the "country" property of an object, you have to type: "obj.country"
"obj" because it is the name of the argument on the function
"country" because it is the property of the object you want.
+ 2
We are not supposed to just give you the answer. We can help you tho, if you show us your attempt and doubts.
You wouldn't even benefit from us just giving the answers, cause you would not be learning
+ 2
Alexandre I just want to know how to do this as i don't know "how to get value of property with key country"
What should I do as i searched in Google and i found two functions
"Object.values" and "Object.keys"
But no one is working.
Are there any other functions?
+ 2
The idea is that you have an object, which is kinda of a collection of variables. For example, you can have an object that is called "sachin"(which is your profile name).
And there, you can store your age, nationality, and other things. These are the "properties" on the instructions.
So, if I write
var sachin = {
age: 20,
country: "India"
}
In this case, if I type "sachin.country", it'll return "India"
+ 2
You're welcome :)
+ 1
Alexandre Thanks bro actually i didn't noticed country and i thoughts, i have to return all keys and values
Thanks â