how to write a range of numbers in if condition js 1

how to write a range of numbers in if condition js

function between(value,first,last) {

 let lower = Math.min(first,last) , upper = Math.max(first,last);
 return value >= lower &&  value <= upper ;

}

Here is what the above code is Doing:
1. It's taking the minimum of the first and last values and assigning it to the variable lower.
2. It's taking the maximum of the first and last values and assigning it to the variable upper.
3. It's returning whether the value is greater than or equal to the lower value and less than or equal to the upper value.

Similar Posts