← Back to challenges

Return Sole Element in a Set

JavaScriptHardlanguage_fundamentalsobjects

Instructions

Given a set containing an element, return the sole element.

Examples

const first = new Set();
first.add(1);
elementSet(first) ➞ 1

const second = new Set();
second.add("apple");
elementSet(second) ➞ "apple"

const third  = new Set();
third.add(false);
elementSet(third) ➞ false

Notes

Set elements may be a string, boolean or number.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Simple OOP Calculator