Get Average
Calculates the average of a set of provided numbers, rounding the result to three decimal places.
getAverage
The getAverage function calculates the average of a set of provided numbers, rounding the result to three decimal places. It returns NaN if no valid numbers are provided.
Function Signature
function getAverage(...numbers: Numeric[]): numberParameters
numbers(Numeric[]): A list of numbers or numeric strings to calculate the average.
Return Value
number: The average of the provided numbers, rounded to three decimal places. If no valid numbers are provided, it returnsNaN.
Example Usage
playground.ts
Notes
- Automatically skips invalid or non-numeric values.
- Rounds the result to three decimal places.
- Works with both
numberand numeric string types (e.g."5","10.2").
Aliases
averagecalculateAverage
Last updated: Tue, Jun 16, 2026 07:49:37PM (UTC)
