Google News
logo
Lodash - Interview Questions
Lodash _.random() Method
The _.random() function produces random values between the inclusive lower and upper bounds.
Example :
<!DOCTYPE html>
<html>
<head>
    <title>Lodash Tutorial</title>
    <script src="https://cdn.jsdelivr.net/npm/lodash@4.17.11/lodash.min.js"></script>
    <script type="text/javascript">
  // Getting array slice
  var r = _.random(15);
  console.log(r);

  r = _.random(5, 15);
  console.log(r);
    </script>
</head>
<body></body>
</html>
Output :
8
7
Advertisement