To use the inRange
function from lodash library in Typescript, you first need to install lodash using the npm package manager:
19 chars2 lines
After installing lodash, you can import the inRange
function in your typescript file and use it as follows:
index.ts103 chars6 lines
Here, the inRange
function takes three arguments: the number to check, the start of the range and the end of the range, and returns a boolean value indicating whether the number falls within the range or not.
In the above code, inRange(3, 1, 5)
returns true
because 3
falls within the range of 1
to 5
, and therefore the if condition is true
and logs the message '3 is in range of 1 to 5' to the console.
gistlibby LogSnag