The following snippet returns a random number between min (inclusive) and max (exclusive).
Math.max() returns the largest number from a set of numbers. Pass each number in as an argument.
Returns the largest integer (whole number) less than or equal to a number.
Get the absolute (positive) value of a number.
Format a number to a fixed number of decimal places. Pass in the number of decimal places as an argument
Convert a string into an integer (a whole number).
Use Intl.NumberFormat to enable country / currency sensitive formatting.
Do you useMath.pow() to raise a number to a power? Did you know you can use the exponent operator ** as well?
Destructure the array to get x1, y1, x2 and y2. Calculate the midpoint for each dimension by dividing the sum of the two endpoints by 2.
Use Math.round() and template literals to round the number to the specified number of digits. Omit the second argument, decimals, to round to an integer.