---
title: "Calculate the average value"
description: "Compute the average of an array or list of numbers in TypeScript."
date: "2025-10-02"
tags: ["typescript","math","average","frontend"]
canonical: "/snippets/typescript/number/average"
---

import { Code } from '@astrojs/starlight/components'
import Source from './average.ts?raw'

## Calculate the average value

Accept an array of numbers or a list of numbers and return the average value.

<Code code={Source} lang="ts" title="average.ts" wrap />
