Advertisement
bai_onzi

Clone Objects // Objects Practice

Apr 11th, 2023
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Clone Objects 34 points
  2.  
  3. export default function (data) {
  4.   // your code starts here
  5.   const primitiveArrCopy = {...data};
  6.   for(const key in primitiveArrCopy){
  7.     if(Array.isArray(primitiveArrCopy[key])){
  8.       primitiveArrCopy[key] = [...primitiveArrCopy]
  9.     }
  10.   }
  11.   return primitiveArrCopy
  12.   // your code ends here
  13. }
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement