javascript number if 00 truncate

Solutions on MaxInterview for javascript number if 00 truncate by the best coders in the world

showing results for - "javascript number if 00 truncate"
Elia
20 Feb 2017
1Number.prototype.toFixedDown = function(digits) {
2    var re = new RegExp("(\\d+\\.\\d{" + digits + "})(\\d)"),
3        m = this.toString().match(re);
4    return m ? parseFloat(m[1]) : this.valueOf();
5};
6
7[   5.467.toFixedDown(2),
8    985.943.toFixedDown(2),
9    17.56.toFixedDown(2),
10    (0).toFixedDown(1),
11    1.11.toFixedDown(1) + 22];
12
13// [5.46, 985.94, 17.56, 0, 23.1]
14