JS Built-ins
← Set51 / 85
Setunionintermediate

Set union() β€” combined size

πŸ“– Usage Example
const a = new Set([1, 2])
const b = new Set([2, 3])
const all = a.union(b)
console.log([...all]) // β†’ [1, 2, 3]

Use Set.union() to combine two sets into a new set containing all unique values.

Set.prototype.union() (ES2025)

setA.union(setB) returns a new Set with all elements from both Sets.

Challenge: Verify the size of the union.

πŸ’‘ Hints (1)
  • β€’ union() returns a new Set containing all elements from both Sets