The Merger

Medium+25 XP

Mission Briefing

Two rival trading guilds have decided to merge their inventories. You must write an algorithm that cleanly combines their assets into a unified master ledger.

The Concept: Object Spreading

The spread operator (...) allows you to quickly copy and merge properties from multiple objects into a brand new object. Example:

const obj1 = { a: 1 };
const obj2 = { b: 2 };
const merged = { ...obj1, ...obj2 }; // { a: 1, b: 2 }

The Objective

Your function receives two objects: obj1 and obj2.

  1. Use the spread operator to combine all properties from both into a new object.
  2. Return the new merged object.

01EXAMPLE 1

Inputobj1 = { a: 1 }, obj2 = { b: 2 }
Output{ a: 1, b: 2 }

Constraints

  • Return a new combined object.
CoreES6+Objects
JavaScript
Loading...
3 Hidden

Input Arguments

obj1{"a":1}
obj2{"b":2}

Expected Output

{"a":1,"b":2}

Click RUN to test your solution