Lodash.js – inRange() function

A simple Lodash.js example of the inRange() function, we can check in our case, if the provided value is between 25 and 150, excluding the comparison with the border values.
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="Tizen example"/>
    <title>Tizen lodash.js example</title>
    <script src="js/lodash.min.js"></script>
</head>
<body>
<div id="first">
</div>
<br>
<div id="second">
</div>

<script>

    var firstDiv = document.getElementById('first');
    var secondDiv = document.getElementById('second');

    var firstValue = 35;

  firstDiv.innerHTML = "Having the value " + firstValue + " using the inRange function we can check if the provided value is between 25 and 150, excluding the comparison with those values...";

    var result = _.inRange(firstValue, 25, 150);

  secondDiv.innerHTML = "...and we get: " + result;

</script>
</body>

</html>

Responses

0 Replies