Thursday, July 31, 2014

javascript round decimal to preferred number of decimal places

function round(value, decimals) {
    return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals);
}

No comments: