Utils.roundToNearest()

Return the number given as first parameter rounded to the nearest multiple of the number given as second parameter

Parameters

NameTypeDescription
1xnumber
2nearestnumber

Return value

number

the result

Usage

import {Utils} from '@lcluber/type6js';

let number = 2.563995;
let roundToNearest = Utils.roundToNearest(number, 0.5);
console.log(roundToNearest); //(2.5)