JS Built-ins
← Set16 / 85
Sethasbeginner

Set has() β€” existing value

πŸ“– Usage Example
const s = new Set([1, 2, 3])
s.has(2)   // β†’ true
s.has(99)  // β†’ false

Use Set.has() to check if a value exists in the set.

Set.prototype.has()

has(value) returns true if the value is in the Set.

Challenge: Verify that has() returns true for an existing value.

πŸ’‘ Hints (1)
  • β€’ has() returns true if the value exists in the Set