-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
  • 31
  • 3
  • 8

1 Answers1

-2

Update your function to this:

function addProperty(obj, key) {
    obj[key] = true;
    return obj;
}
snorkpete
  • 14,278
  • 3
  • 40
  • 57
luk492
  • 350
  • 3
  • 15