function makeValidator(min, max) {
return value => value >= min && value <= max
}
const isAdult = makeValidator(18, 120)
isAdult(25) // β true
isAdult(15) // β falseValidator factories close over min and max bounds, allowing reusable range-checking functions to be created with any boundary values.
Create a factory that produces validator functions for checking if values fall within a range.
Challenge: Create a makeValidator(min, max) function that returns a function. The returned function takes a value and returns true if the value is between min and max (inclusive), otherwise false.
Example:
const isInRange = makeValidator(10, 20)
isInRange(15) // true
isInRange(5) // false
isInRange(25) // false