Accessing object properties one

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
}
Test Cases:
myFunction({ continent: 'Asia', country: 'Japan' })
Expected
'Japan'
myFunction({ country: 'Sweden', continent: 'Europe' })
Expected
'Sweden'

How to solve it

Objects consist of key-value pairs. In order to access a specific value within an object, you have to know the corresponding key. In this case, we want to access a value within an object that has the key country. The value is a string with the name of the country.

But, the value of an object property could have any value, for example a number or even another object that has even more properties.

There are two distinct ways to access a property value of an object with a key. The first one is by using the dot notation. Simply write down the object name and the key of the requested property, separated by a dot:

const obj = { x: 1 };
console.log(obj.x);
// output: 1

The other way to access an object property is using the square bracket notation. Instead of using a dot, type the key in string format encapsulated by square brackets:

const obj = { x: 1 };
console.log(obj['x']);
// output: 1

We will learn about the differences between the two approaches in this challenge.

Objects vs. arrays:

This way of accessing values within objects is very different from how you would access values within arrays. In order to get a specific array value, you have to know exactly at which position it is located (see this challenge for a comparison). Also, if the array value was removed in the meantime, you might get the wrong value. But, if an object property was removed before accessing it, you will know that it does not exist because you get undefined.