I am working on a pre-boot camp coding problem. I am passing in an object (ourDog) and a key (fiendly) into a function that creates a new property (key:value pair) and assigns a value of true to that key. Looking at the output, the property is added, but the key does not have the assigned value of 'friendly', it has the parameter name of key. I expected the key:value pair to (friendly: true). Here is the code.
var ourDog = {
"name": "Camper",
"legs": 4,
"tails": 1,
"friends": ["everything!"]
};
function addProperty(anObject, key) {
anObject.key = true;
return anObject;
};
var output = addProperty(ourDog, 'friendly');
console.log(output);
{name: "Camper", legs: 4, tails: 1, friends: Array(1), key: true}