percent

percent

Returns percentage value of a number from a maximum number

Import

import { percent } from '@fullstacksjs/toolbox';

Signature

function percent(value: number, max: number): number {}

Examples

percent(0, 10)   // 0
percent(1, 10)   // 10
percent(-1, 10)  // 0
percent(20, 10)  // 100
percent(NaN, 10) // 0
percent(10, NaN) // 0
percent(1, 3)    // 33.33333333333333