Numbers.closest()
Syntax
function closest(source: number, ...targets: number[]): number;
Finds the number closest to another.
Parameters | |
source
|
An arbitrary number. |
targets
Rest
|
A set of numbers from which to find the closest to |
Example
import { Numbers } from 'potence';
Numbers.closest(5, 8, 1); // -> 8
Remarks
If multiple numbers are equally close to source
, this function returns the
one that comes first in the argument list.
If no targets
are specified, returns source
.