-1

Given an object, and a key, "addProperty" sets a new property on the given object with a value of true.

var myObj = {};
addProperty(myObj, 'myProperty');
console.log(myObj.myProperty); // --> true

this is my code, but it's wrong:

function addProperty(obj, key) {
  // your code here
  obj.key = key;
    obj.values = true;
    return obj;
}
Shirley
  • 29
  • 3
  • 8

1 Answers1

-2

Update your function to this:

function addProperty(obj, key) {
    obj[key] = true;
    return obj;
}
snorkpete
  • 13,778
  • 3
  • 39
  • 56
luk492
  • 342
  • 2
  • 13