Return Sole Element in a Set

Published by BijogFc24 in

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.

Watch a quick demo on how Edabit works.