Average()Method : JMath
Calculates the average of a variable amount of numbers
Values
function Average(...values: Number): float
Parameters
- values
- A variable length rest parameter which can be passed any amount of numbers.
- Has no default value - required
Returns
- float
- The average of all passed parameters expressed in an unrounded float.
Common Errors
- SyntaxError: At least 1 parameter is not a number or float
- Often occurs when values is accidentaly passed an Array.
Example
const average = JMath.Average(3, 8, 1, 9, 3, 8, 25); // Should return: 8.14285714285
Notes
- This method is probably most useful when Array deconstruction is used to dynamically pass a larger collection of numbers.
Log
JMAC a | 17-05-25
Method introduced.
JMAC g_a | 02-07-25
Method converted to Cast structure as test phase.
JMAC 1a | 02-09-25
Method reverted to normal structure.
Error fixes.