If I have the following
var lowerBound = 0;
var higherBound = 100;
var inputVar = document.getElementById('input').value; // e.g. 51
How do I programatically determine if the inputVar
is closer to variable lowerBound
or variable higherBound
?
Meaning, if the user inputs '51
', the function should return '100
'. But if the user inputs '49
', it should return '0
'.