var n = Math.random(); n = Math.floor((n * 6) + 1); // if you want your numbers to start at 1 and end at 6 console.log(n);