I have the following code:
var myObj = {apples:"five", pears:"two"};
function myFunction(x) {
alert(myObj.x);
};
When I run myFunction(apples) I don't get an alert saying five, but I get an alert saying undefined.
How do I get the result I want by using the function parameter x with the object myObj
The result I want is it to say 'five' instead of 'undefined'.
myObj[x]