Files
30-seconds-of-code/node_modules/underscore.string/toNumber.js
2019-08-20 15:52:05 +02:00

6 lines
195 B
JavaScript

module.exports = function toNumber(num, precision) {
if (num == null) return 0;
var factor = Math.pow(10, isFinite(precision) ? precision : 0);
return Math.round(num * factor) / factor;
};