Toolbox-XToolbox-X

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[]): number

Parameters

  • 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 returns NaN.

Example Usage

playground.ts

Notes

  • Automatically skips invalid or non-numeric values.
  • Rounds the result to three decimal places.
  • Works with both number and numeric string types (e.g. "5", "10.2").

Aliases

  • average
  • calculateAverage

Last updated: Tue, Jun 16, 2026 07:49:37PM (UTC)

On this page