Question: Write a function `keyAdderUniqueVal(object, key, value)` that accepts an object, a string to be set as a key in that object, and a value. When

Write a function `keyAdderUniqueVal(object, key, value)` that accepts an

object, a string to be set as a key in that object, and a value. When invoked

the function should assign the key and value arguments as a key value pair in

the object argument ONLY IF the value is not already a value for a different

key in the object. Return the mutated object.

See below for examples

let cat = { name: 'Willie', color: 'orange' };

keyAdderUniqueVal(cat, "toy", "yarn"); // => {name: "Willie", color: "orange", toy: "yarn"}

keyAdderUniqueVal(cat, "fruit", "orange"); // => {name: "Willie", color: "orange", toy: "yarn"}

console.log(cat); // { name: "Willie", color: "orange", toy: "yarn" }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!