. Advertisement .
..3..
. Advertisement .
..4..
How can I generate integer with math random in java? I will be grateful for your solutions.
Assuming that you want to generate a random integer between 0 and 1000, here is the command line:
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
console.log(getRandomInt(1000));
// expected output: 0, 1 or 999
I’ve seen this on another forum and this helped me