The most straightforward way to generate a random number in JavaScript is to use Math.random().
Math.random()
Here’s how you round numbers in JavaScript using Math.round(), Math.ceil(), and Math.floor().
Math.round()
Math.ceil()
Math.floor()
JavaScript doesn’t have built-in complex number support, but you can roll your sleeves up and handle it with objects and math.