momo3141

Task 2

Jan 11th, 2023
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export default function (data) {
  2.   // your code starts here
  3.   let result = {};
  4.   let keys = data['keys'];
  5.   let objOne = data['first'];
  6.   let objTwo = data['second'];
  7.  
  8.   for (let key of keys){
  9.     let tempArray = [];
  10.     if(objOne.hasOwnProperty(key) && objTwo.hasOwnProperty(key)){
  11.       tempArray.push(objOne[key]);
  12.       tempArray.push(objTwo[key]);
  13.       result[key] = tempArray
  14.     } else if (objOne.hasOwnProperty(key)){
  15.       result[key] = objOne[key]
  16.     } else if (objTwo.hasOwnProperty(key)){
  17.       result[key] = objTwo[key]
  18.     } else {
  19.       result[key] = null;
  20.     }
  21.  
  22.   }
  23.  
  24.   return result;
  25.   // your code ends here
  26. }
Advertisement
Add Comment
Please, Sign In to add comment