💹 Calculates the value of a given percentage of a number.

Syntax

TypeScript
import { percentageOf } from '@opentf/std';

percentageOf(percentage: number, num: number): number

Parameters

  • percentage: The percentage value.

  • num: The number to calculate the percentage of.

Returns

The calculated value.

Examples

TypeScript
percentageOf(0, 0); //=> 0

percentageOf(1, 1); //=> 0.01

percentageOf(10, 80); //=> 8

percentageOf(50, 900); //=> 450

percentageOf(17.5, 10); //=> 1.75
Last updated on
Edit this page