var getUniqRandomInt = (function() { var numbers = []; return function fn(max) { var n = Math.floor(Math.random() * (max - min + 1)) + min; if(numbers.indexOf(n) !== -1) { n = fn(max); } numbers.push(n); return n; }; })();