UNPKG

ds-algo-study

Version:

Just experimenting with publishing a package

23 lines (17 loc) 735 B
/*********************************************************************** Write a function `valuePair(obj1, obj2, key)` that takes in two objects and a key (string). The function should return an array containing the corresponding values of the objects for the given key. Examples: let object1 = {name: 'One', location: 'NY', age: 3}; let object2 = {name: 'Two', location: 'SF'}; valuePair(object1, object2, 'location'); // => [ 'NY', 'SF' ] valuePair(object1, object2, 'name'); // => [ 'One', 'Two' ] ***********************************************************************/ function valuePair(obj1, obj2, key) { let val1 = obj1[key]; let val2 = obj2[key]; let arr = [val1, val2]; return arr; } module.exports = valuePair;