function randomWithStep(min, max, step) { let prev; return function () { let current; function countFormula() { current = min + (step * Math.floor(Math.random()*(max-min)/step)); } do { countFormula(); } while (prev === current); prev = current; return current; }; } let randomNumber = randomWithStep(10, 80, 10); randomNumber();