Skip to content

Function: percentage() ​

ts
function percentage(part, total): number;

What percent part is of total (0–100 scale). 计算 part 占 total 的百分比(0–100)。

Parameters ​

ParameterTypeDescription
partnumberPartial value / 部分值
totalnumberWhole value / 总值

Returns ​

number

Percentage / 百分比

Example ​

ts
percentage(30, 200) // => 15

Since ​

1.0.0

Released under the MIT License.