This function returns the maximum value from a set.
JavaScript:
let maxOfSet = set => Math.max(...set);
// Example
console.log(maxOfSet(new Set([1, 2, 3, 4, 5]))); // 5
console.log(maxOfSet(new Set([-10, -20, -30, -40, -50]))); // -10
TypeScript:
let maxOfSet = (set: Set): number => Math.max(...set);
// Example
console.log(maxOfSet(new Set([1, 2, 3, 4, 5]))); // 5
console.log(maxOfSet(new Set([-10, -20, -30, -40, -50]))); // -10