The following snippet returns a random number between min (inclusive) and max (exclusive).
Math Related
Get the largest number from a set of numbers
Math.max() returns the largest number from a set of numbers. Pass each number in as an argument.
Return the largest integer less than or equal to a number
Returns the largest integer (whole number) less than or equal to a number.
Get the absolute value of a number with JavaScript
Get the absolute (positive) value of a number.
Format a number to a fixed number of decimal places
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)
Convert a string into an integer (a whole number).
Take a number and return it in the specified currency formatting
Use Intl.NumberFormat to enable country / currency sensitive formatting.
The Exponent Operator
Do you useMath.pow() to raise a number to a power? Did you know you can use the exponent operator ** as well?
Calculate the midpoint between two pairs of (x,y) points
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.
Round a number to a specified amount of digits
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.