Is math.random() a good method for a random/pseudo-random number generator?
getRandomInt() random() is a pseudo-random number as no computer can generate a truly random number, that exhibits randomness over all scales and over all sizes of data sets.
The Math.round() function returns the value of a number rounded to the nearest integer.
console.log(Math.round(0.9));
// expected output: 1
console.log(Math.round(5.95), Math.round(5.5), Math.round(5.05));
// expected output: 6 6 5
console.log(Math.round(-5.05), Math.round(-5.5), Math.round(-5.95));
// expected output: -5 -5 -6
I would say the best method for random numbers is math.random(). good luck!