You have a global function which is also a global variable. Globals are generally a bad thing because they eat up your namespace and cause naming collisions.
If you're not worried about that you can let JSLint know which globals you are using by adding the following comment to the top of each file you lint:
/*globals random_num, $ */
I've added $
to demonstrate that you can provide a list of globals.
However since you're using Node I'd recommend adding this to a Utils
module. JSLint will not complain about that since you'll be declaring the module with var
.
utils.js
module.exports = {
random_num: function random_num($value) {
$result = Math.floor(Math.random() * $value);
return $result;
}
};
Elsewhere:
var utils = require('./utils');
utils.random_num();