Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

Students also viewed these Databases questions