Create a type predicate function that checks if input passes fn and has a length matching the given length or falling within the given range.
input
fn
length
const twoCharString = withLength(isString, 2);twoCharString('ab'); // truetwoCharString('abc'); // falseconst stringRange = withLength(isString, [1, 3]);stringRange('a'); // truestringRange('abc'); // truestringRange('abcd'); // false Copy
const twoCharString = withLength(isString, 2);twoCharString('ab'); // truetwoCharString('abc'); // falseconst stringRange = withLength(isString, [1, 3]);stringRange('a'); // truestringRange('abc'); // truestringRange('abcd'); // false
Create a type predicate function that checks if
inputpassesfnand has alengthmatching the givenlengthor falling within the given range.Example