JSFiddle - React, Tailwind, and code Playground

JavaScript

function mergeRecursive(obj1, obj2) {

  for (var p in obj2) {
    try {
      // Property in destination object set; update its value.
      if ( obj2[p].constructor==Object ) {
        obj1[p] = mergeRecursive(obj1[p], obj2[p]);

      } else {
        obj1[p] = obj2[p];

      }

    } catch(e) {
      // Property in destination object not set; create it and set its value.
      obj1[p] = obj2[p];

    }
  }

  return obj1;
}

var person1 = {
    hello: {
        "david": {
            "hours": "44",
            "money": "22"
        }
    }
};


var person2 = {
    world: {
        "pearce": {
            "hours": "21",
            "money": "11"
        }
    }
};

console.log(mergeRecursive(person1, person2));