I have a set of numbers and an init number.
const mySet = new Set([1, 4, 5])
const initVal = 2
I want to find the smallest number greater than the initVal in mySet.
I could do something like...
let myArray = Array.from(mySet)
let smallestNumSoFar = Infinity
for (let num of myArray) {
if (num > initVal && num < smallestNumSoFar) smallestNumSoFar = num;
}
But I was looking at this answer for python and it looks soo clean. Can anyone think of a nice one liner for javascript to do this? Something like Math.min of numbers>X in mySet