I have a function that formats a number (even a float) to a  German decimal format. I got this function from here https://stackoverflow.com/questions/149055/how-can-i-format-numbers-as-money-in-javascript and it works. But every time I want to format a number that I stored in a variable I have to add .format(2, 3, '.', ',').EX: I have an int :45122.9 and I want to format it I have this function:Number.prototype.format = function(n, x, s, c) {    var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\D' : '$') + ')',        num = this.toFixed(Math.max(0, ~~n));    return (c ? num.replace('.', c) : num).replace(new RegExp(re, 'g'), '$&' + (s || ','));};var netto=45122.9;document.write(netto.format(2, 3, '.', ',')+ ' ' +'');This will format my number as such 45.122,90  .Is there a way to name the function, lets say... formatNumber, add this part to it format(2, 3, '.', ',') and than just call it like this: document.write(formatNumber(netto)); ?
Number to german decimal format converter function
javascript;functional programming;formatting;integer