Javascript Number times(func)
var i = 0;/* w w w . ja va2 s .c o m*/ Number.prototype.times = function(func) { let n = Math.round(this); if (n <= 0) return null; func(); return (n - 1).times(func); } console.log(i);
Number.prototype.times = function (func) { var i;/*from w w w. j a v a2 s.c o m*/ for (i = 0; i < this; i += 1) { func(); } }; function random(min, max) { var floor = +min, ceil = +max; if ((floor % 1 !== 0) || (ceil % 1 !== 0)) { return Math.random() * (ceil - floor) + floor; } return Math.floor(Math.random() * (ceil - floor + 1)) + floor; };